This following code move-constructs S via const &&.
Yet it returns 0, indicating S is not move-constructible!
-
What is the correct behavior of each of the 2 marked constructions in
mainaccording to the standard? -
If returning
0is the correct behavior, what is the rationale behind it?
(Why shouldn't it reflect whether the type is, in fact, constructible via a move?)
#include <algorithm>
struct S
{
S( ) { }
S(S &) { } // = delete; doesn't make any difference
S(S const &) { } // = delete; doesn't make any difference
S(S const &&) { }
S(S &&) = delete;
};
int main()
{
S const s1;
S s2(std::move(s1)); // OK for >= C++11
S s3((S())); // OK for >= C++17, error for <= C++14
return std::is_move_constructible<S>::value;
}
Aucun commentaire:
Enregistrer un commentaire