p1.cpp
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// RUN: %clang_cc1 -std=c++2a -x c++ -verify %s
template<typename T> concept True = true;
template<typename T> concept Foo = True<T*>;
template<typename T> concept Bar = Foo<T&>;
template<typename T> requires Bar<T> struct S { };
template<typename T> requires Bar<T> && true struct S<T> { };
template<typename T> concept True2 = sizeof(T) >= 0;
template<typename T> concept Foo2 = True2<T*>;
// expected-error@-1{{'type name' declared as a pointer to a reference of type 'type-parameter-0-0 &'}}
template<typename T> concept Bar2 = Foo2<T&>;
// expected-note@-1{{while substituting into concept arguments here; substitution failures not allowed in concept arguments}}
template<typename T> requires Bar2<T> struct S2 { };
// expected-note@-1{{template is declared here}}
template<typename T> requires Bar2<T> && true struct S2<T> { };
// expected-error@-1{{class template partial specialization is not more specialized than the primary template}}
// expected-note@-2{{while calculating associated constraint of template 'S2' here}}
namespace type_pack {
template<typename... Args>
concept C1 = ((sizeof(Args) >= 0) && ...);
template<typename A, typename... B>
concept C2 = C1<A, B...>;
template<typename T>
constexpr void foo() requires C2<T, char, T> { }
template<typename T>
constexpr void foo() requires C1<T, char, T> && true { }
static_assert((foo<int>(), true));
}
namespace template_pack {
template<typename T> struct S1 {};
template<typename T> struct S2 {};
template<template<typename> typename... Args>
concept C1 = ((sizeof(Args<int>) >= 0) && ...);
template<template<typename> typename A, template<typename> typename... B>
concept C2 = C1<A, B...>;
template<template<typename> typename T>
constexpr void foo() requires C2<T, S1, T> { }
template<template<typename> typename T>
constexpr void foo() requires C1<T, S1, T> && true { }
static_assert((foo<S2>(), true));
}
namespace non_type_pack {
template<int... Args>
concept C1 = ((Args >= 0) && ...);
template<int A, int... B>
concept C2 = C1<A, B...>;
template<int T>
constexpr void foo() requires C2<T, 2, T> { }
template<int T>
constexpr void foo() requires C1<T, 2, T> && true { }
static_assert((foo<1>(), true));
}