The following code compiles in C++17 and does not compile in C++11
class Value
{
public:
Value() = default;
~Value() = default;
Value(const Value&) = default;
Value& operator=(const Value&) = default;
Value(Value&&) = delete;
Value& operator=(Value&&) = delete;
};
int main()
{
auto value = Value{};
}
The message is:
error: call to deleted constructor of 'Value'
auto value = Value{};
^ ~~~~~~~
note: 'Value' has been explicitly marked deleted here
Value(Value&&) = delete;
But if I change to:
int main()
{
Value value{};
}
Then it is fine for both C++11 and C++17. Does this have anything to copy elision introduced in C++17?