C++ Auto Generates Move Constructor With User Declared Destructor? -
according cppreference , this answer, c++ should not automatically generate move constructor if there user declared destructor. checking in practice clang, however, see auto-generated move constructor. following code prints "is_move_constructible: 1":
#include <iostream> #include <type_traits> struct testclass { ~testclass() {} }; int main( int argc, char** argv ) { std::cout << "is_move_constructible: " << std::is_move_constructible<testclass>::value << std::endl; }
am misunderstanding "there no user-declared destructor" or std::is_move_constructible? i'm compiling '-std=c++14' , apple llvm version 7.0.2 (clang-700.1.81).
types without move constructor, copy constructor accepts const t&
arguments, satisfy std::is_move_constructible
, implicitly-declared copy constructor has form t::t(const t&)
.
if implicitly-declared copy constructor deleted, std::is_move_constructible
not satisfied below.
#include <iostream> #include <type_traits> struct testclass { ~testclass() {} testclass(const testclass&) = delete; }; int main( int argc, char** argv ) { std::cout << "is_move_constructible: " << std::is_move_constructible<testclass>::value << std::endl; }
Comments
Post a Comment