I thought that when I delete the move constructor in B, then the following code will still compile fine, since it should still take the copy constructor to build the objects B. Why is the compiler complaining now. Without =deleteit, he never called the copy constructor, since he was not allowed to provide a default move constructor!)
class B{
public:
B(){}
~B(){}
B & operator=(const B & b){
std::cout << " cannot move -> copy " << std::endl;
return *this;
}
B(const B & v){
std::cout << " cannot move -> copy " << std::endl;
}
};
int main()
{
B b( B{} );
}
Compiler output with clang 3.6 ( live code )
main.cpp:27:7: error: call to deleted constructor of 'B'
B b( B{} );
^ ~~~
main.cpp:21:5: note: 'B' has been explicitly marked deleted here
B(B && b) = delete;
^
1 error generated.
source
share