Multiple ChoiceIntermediate 45s
Non-member swap idiom
Why is providing a `swap` overload for your type (found via ADL) preferred over specializing `std::swap`?
Options
- 1ADL-found swap lets generic code pick an efficient customization while still working with std::swap fallback; specializing std::swap is generally not allowed for user types.
- 2Because specializing std::swap is a hard compile error in all cases, so it is simply rejected.
- 3Because an ADL-found swap is always faster than any member or free function swap could be.
- 4Because std::swap can only work on POD types and cannot be used with class types at all.
Think you can answer under pressure?
Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.