#include
template
struct S {
S() = default;
S(const S &) requires (!std::copy_constructible) {}
};
S u;
S v(u); //copy construction
static_assert( !std::copy_constructible );
< /code>
Я ожидал, что программа потерпит неудачу с ошибкой, что -то вроде «удовлетворенности ограничения зависит от себя». И действительно, MSVC не удается, но с довольно неясным сообщением об ошибке: < /p>
(6): error C7608: atomic constraint should be a constant expression
(6): note: the template instantiation context (the oldest one first) is
(6): note: while evaluating concept 'copy_constructible'
Z:/compilers/msvc/14.40.33807-14.40.33811.0/include\concepts(170): note: while evaluating concept 'move_constructible'
Z:/compilers/msvc/14.40.33807-14.40.33811.0/include\concepts(105): note: while evaluating concept 'constructible_from'
(6): error C2131: expression did not evaluate to a constant
(6): note: failure was caused by a read of an uninitialized symbol
(6): note: see usage of 'std::copy_constructible'
Но, как GCC, так и Clang успешно создают программу без каких -либо предупреждений.>
В следующей программе конструктор копирования struct s объявляется с ограничением того, что класс не подходит для копирования: [code]#include
template struct S { S() = default; S(const S &) requires (!std::copy_constructible) {} };
S u; S v(u); //copy construction
static_assert( !std::copy_constructible ); < /code> Я ожидал, что программа потерпит неудачу с ошибкой, что -то вроде «удовлетворенности ограничения зависит от себя». И действительно, MSVC не удается, но с довольно неясным сообщением об ошибке: < /p> (6): error C7608: atomic constraint should be a constant expression (6): note: the template instantiation context (the oldest one first) is (6): note: while evaluating concept 'copy_constructible' Z:/compilers/msvc/14.40.33807-14.40.33811.0/include\concepts(170): note: while evaluating concept 'move_constructible' Z:/compilers/msvc/14.40.33807-14.40.33811.0/include\concepts(105): note: while evaluating concept 'constructible_from' (6): error C2131: expression did not evaluate to a constant (6): note: failure was caused by a read of an uninitialized symbol (6): note: see usage of 'std::copy_constructible' [/code] Но, как GCC, так и Clang успешно создают программу без каких -либо предупреждений.>