Closed
Description
In the following program struct A
has a constructor template A(T)
requiring that the type T
be copy-constructible. At the same time A
itself must have implicitly defined copy-constructor:
#include <type_traits>
struct A {
template <class T>
A(T) requires(std::is_copy_constructible_v<T>) {}
};
static_assert(std::is_copy_constructible_v<A>);
and the last static_assert(std::is_copy_constructible_v) passes in GCC and MSVC, but Clang rejects it, complaining:
error: substitution into constraint expression resulted in a non-constant expression
A(T) requires(std::is_copy_constructible_v<T>) {}
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.1/../../../../include/c++/12.0.1/type_traits:971:30: note: while checking constraint satisfaction for template 'A<A>' required here
: public __bool_constant<__is_constructible(_Tp, _Args...)>
^~~~~~~~~~~~~~~~~~
...
Demo: https://gcc.godbolt.org/z/shKe7W1jr
Related discussion: https://stackoverflow.com/q/70874679/7325599
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done