Std :: is_copy / move_constructible doesn't work even though default copy / move constructors
I have an Input class that has default move / copy constructors.
Input(const Input &) = default;
Input(Input &&) = default;
However, the following statements do not hold.
static_assert(std::is_copy_constructible<Input>(), "Input is not copy-constructible");
static_assert(std::is_move_constructible<Input>(), "Input is not move-constructible");
Why is this?
Here's a complete example:
#include <type_traits>
class A {
public:
A(const A &) = default;
static_assert(std::is_copy_constructible<A>(), "");
};
int main() {
// your code goes here
return 0;
}
+3
source to share
4 answers
This piece of code ( live on Ideone ) works fine:
#include <type_traits>
class Input {
public:
Input(const Input &) = default;
Input(Input &&) = default;
};
int main() {
static_assert(std::is_copy_constructible<Input>(), "");
static_assert(std::is_move_constructible<Input>(), "");
}
+1
source to share