How do I write a concept that demands that the class has a noexcept
constructor? For example, the following static_assert
is true in Clang 15.0.7, although I feel that it shouldn't.
class Ragdoll {
int age_ = -1;
public:
Ragdoll(int age) /* noexcept */ : age_(age) {}
int meow() const;
int lose_hair();
};
template<typename Cat>
concept cat = requires(Cat cat) {
noexcept(Cat{42});
{ cat.meow() } -> std::same_as<int>;
};
static_assert(cat<Ragdoll>);
What is the noexcept
expression doing then anyway in the concept? (Feel free to also link any good concepts tutorials)