Closed
Description
I'm trying to create a specialization of the Foo
class template that only accepts specializations of the Bar
class template as a template argument. However, clang ignores my IsBar<T>
constraint and accepts int
as a template argument.
template<typename>
struct Foo;
template<typename>
struct Bar {};
template<typename T>
concept IsBar = requires (T t) { [] <typename U> (Bar<U>& c) {} (t); };
template<IsBar T>
struct Foo<T> {
static void test() {}
};
int main() {
Foo<Bar<int>>::test(); // OK
// static_assert(!IsBar<int>);
// the following line compiles
// unless i uncomment the static_assert:
Foo<int>::test(); // this should not compile
}
static_assert
'ing !IsBar<int>
seems to make it correctly reject int
Metadata
Metadata
Assignees
Type
Projects
Status
Done