1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
4 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
8 template<bool, class = void> struct enable_if
{};
9 template<class T
> struct enable_if
<true, T
> { using type
= T
; };
10 template<bool B
, class T
= void> using enable_if_t
= typename enable_if
<B
, T
>::type
;
14 namespace similar_to_user_code
{
15 // expected-note@+2 {{candidate template ignored: requirement 'sizeof(char) != 1' was not satisfied [with T = char]}}
16 template<class T
, class = std::enable_if_t
<sizeof(T
) != 1>>
19 // expected-note@+2 {{candidate template ignored: requirement 'sizeof(char) != 1' was not satisfied [with T = char]}}
20 template<class T
, std::enable_if_t
<sizeof(T
) != 1>* = nullptr>
23 // expected-note@+2 {{candidate template ignored: requirement 'sizeof(char) != 1' was not satisfied [with T = char]}}
25 std::enable_if_t
<sizeof(T
) != 1, void> f(T
, long);
28 f('x', 0); // expected-error{{no matching function}}
32 namespace similar_to_libcxx_version_14
{
33 template<bool, class = void> struct enable_if
{};
34 template<class T
> struct enable_if
<true, T
> { using type
= T
; };
35 template<bool B
, class T
= void> using __enable_if_t
= typename enable_if
<B
, T
>::type
;
37 // expected-note@+2 {{candidate template ignored: requirement 'sizeof(char) != 1' was not satisfied [with T = char]}}
38 template<class T
, class = __enable_if_t
<sizeof(T
) != 1>>
41 // expected-note@+2 {{candidate template ignored: requirement 'sizeof(char) != 1' was not satisfied [with T = char]}}
42 template<class T
, __enable_if_t
<sizeof(T
) != 1>* = nullptr>
45 // expected-note@+2 {{candidate template ignored: requirement 'sizeof(char) != 1' was not satisfied [with T = char]}}
47 __enable_if_t
<sizeof(T
) != 1, void> f(T
, long);
50 f('x', 0); // expected-error{{no matching function}}
54 namespace similar_to_libcxx_version_13
{
55 template<bool> struct _MetaBase
{};
56 template<> struct _MetaBase
<true> { template<class R
> using _EnableIfImpl
= R
; };
57 template<bool B
, class T
= void> using _EnableIf
= typename _MetaBase
<B
>::template _EnableIfImpl
<T
>;
59 // expected-note@+2 {{no member named '_EnableIfImpl'}}
60 template<class T
, class = _EnableIf
<sizeof(T
) != 1>>
63 // expected-note@+2 {{no member named '_EnableIfImpl'}}
64 template<class T
, _EnableIf
<sizeof(T
) != 1>* = nullptr>
67 // expected-note@+2 {{no member named '_EnableIfImpl'}}
69 _EnableIf
<sizeof(T
) != 1, void> f(T
, long);
72 f('x', 0); // expected-error{{no matching function}}
76 namespace not_all_names_are_magic
{
77 template<bool, class = void> struct enable_if
{};
78 template<class T
> struct enable_if
<true, T
> { using type
= T
; };
79 template<bool B
, class T
= void> using a_pony
= typename enable_if
<B
, T
>::type
;
81 // expected-note@-2 {{candidate template ignored: disabled by 'enable_if' [with T = char]}}
82 template<class T
, class = a_pony
<sizeof(T
) != 1>>
85 // expected-note@-6 {{candidate template ignored: disabled by 'enable_if' [with T = char]}}
86 template<class T
, a_pony
<sizeof(T
) != 1>* = nullptr>
89 // expected-note@-10 {{candidate template ignored: disabled by 'enable_if' [with T = char]}}
91 a_pony
<sizeof(T
) != 1, void> f(T
, long);
94 f('x', 0); // expected-error{{no matching function}}