vendredi 13 mars 2020

Why wasn't std::swap marked constexpr before C++20?

In C++20, std::swap becomes a constexpr function.

I know that the standard library really lagged behind the language in marking things constexpr, but by 2017, <algorithm> was pretty much constexpr as were a bunch of other things. Yet - std::swap wasn't. I vaguely remember there being some strange language defect which prevent that marking, but I forget the details.

Can someone explain this succinctly and clearly?

Motivation: Need to understand why it may be bad idea to mark an std::swap()-like function constexpr in C++11/C++14 code.

Aucun commentaire:

Enregistrer un commentaire