@@ -40,6 +40,10 @@ template<typename R, typename... T>
4040
4141void test01 ()
4242{
43+ struct T { T(int ) { } };
44+ struct NT { NT(int ) noexcept { } };
45+ struct Ex { explicit Ex (int ) noexcept { } };
46+
4347 using func_type = void (*)();
4448 static_assert ( ! is_nt_invocable< func_type>(), " " );
4549
@@ -55,28 +59,46 @@ void test01()
5559 static_assert ( ! is_nt_invocable< mem_type, int >(), " " );
5660 static_assert ( ! is_nt_invocable< mem_type, int & >(), " " );
5761
58- static_assert ( is_nt_invocable< mem_type, X& >(), " " );
59- static_assert ( is_nt_invocable_r< int , mem_type, X& >(), " " );
60- static_assert ( is_nt_invocable_r< int &, mem_type, X& >(), " " );
61- static_assert ( is_nt_invocable_r< long , mem_type, X& >(), " " );
62- static_assert ( is_nt_invocable_r< int &, mem_type, X* >(), " " );
62+ static_assert ( is_nt_invocable< mem_type, X& >(), " " );
63+ static_assert ( is_nt_invocable_r< int , mem_type, X& >(), " " );
64+ static_assert ( is_nt_invocable_r< int &, mem_type, X& >(), " " );
65+ static_assert ( is_nt_invocable_r< long , mem_type, X& >(), " " );
66+ static_assert ( ! is_nt_invocable_r< long &, mem_type, X& >(),
67+ " conversion fails, cannot bind long& to int" );
68+ static_assert ( is_nt_invocable_r< int &, mem_type, X* >(), " " );
69+
70+ static_assert ( ! is_nt_invocable_r< T, mem_type, X& >(),
71+ " conversion throws" );
72+ static_assert ( is_nt_invocable_r< NT, mem_type, X& >(), " " );
73+ static_assert ( ! is_nt_invocable_r< Ex, mem_type, X& >(),
74+ " conversion fails, would use explicit constructor" );
6375
6476 using memfun_type = int (X::*)();
6577
66- static_assert ( ! is_nt_invocable< memfun_type >(), " " );
67- static_assert ( ! is_nt_invocable< memfun_type, int >(), " " );
68- static_assert ( ! is_nt_invocable< memfun_type, int & >(), " " );
69- static_assert ( ! is_nt_invocable< memfun_type, X& >(), " " );
70- static_assert ( ! is_nt_invocable< memfun_type, X* >(), " " );
78+ static_assert ( ! is_nt_invocable< memfun_type >(), " no object" );
79+ static_assert ( ! is_nt_invocable< memfun_type, int >(), " no object" );
80+ static_assert ( ! is_nt_invocable< memfun_type, int & >(), " no object" );
81+ static_assert ( ! is_nt_invocable< memfun_type, X& >(), " call throws" );
82+ static_assert ( ! is_nt_invocable< memfun_type, X* >(), " call throws" );
83+
84+ static_assert ( ! is_nt_invocable_r< T, memfun_type, X& >(), " call throws" );
85+ static_assert ( ! is_nt_invocable_r< NT, memfun_type, X& >(), " call throws" );
86+ static_assert ( ! is_nt_invocable_r< Ex, memfun_type, X& >(), " call throws" );
7187
7288#if __cpp_noexcept_function_type
7389 using memfun_type_nt = int (X::*)() noexcept ;
7490
75- static_assert ( ! is_nt_invocable< memfun_type_nt >(), " " );
76- static_assert ( ! is_nt_invocable< memfun_type_nt, int >(), " " );
77- static_assert ( ! is_nt_invocable< memfun_type_nt, int & >(), " " );
91+ static_assert ( ! is_nt_invocable< memfun_type_nt >(), " no object " );
92+ static_assert ( ! is_nt_invocable< memfun_type_nt, int >(), " no object " );
93+ static_assert ( ! is_nt_invocable< memfun_type_nt, int & >(), " no object " );
7894 static_assert ( is_nt_invocable< memfun_type_nt, X& >(), " " );
7995 static_assert ( is_nt_invocable< memfun_type_nt, X* >(), " " );
96+
97+ static_assert ( ! is_nt_invocable_r< T, memfun_type_nt, X& >(),
98+ " conversion throws" );
99+ static_assert ( is_nt_invocable_r< NT, memfun_type_nt, X& >(), " " );
100+ static_assert ( ! is_nt_invocable_r< Ex, memfun_type_nt, X& >(),
101+ " conversion fails, would use explicit constructor" );
80102#endif
81103
82104 struct F {
@@ -89,12 +111,44 @@ void test01()
89111 };
90112 using CF = const F;
91113
92- static_assert ( ! is_nt_invocable_r< int &, F >(), " " );
93- static_assert ( is_nt_invocable_r< long &, CF >(), " " );
94- static_assert ( ! is_nt_invocable_r< short &, F, int >(), " " );
95- static_assert ( is_nt_invocable_r< char &, F&, int >(), " " );
96- static_assert ( is_nt_invocable_r< char &, CF, int >(), " " );
97- static_assert ( is_nt_invocable_r< char &, CF&, int >(), " " );
98-
99- static_assert ( ! is_nt_invocable< F, int , int >(), " " );
114+ static_assert ( ! is_nt_invocable< F >(), " call throws" );
115+ static_assert ( is_nt_invocable< CF >(), " " );
116+
117+ static_assert ( ! is_nt_invocable_r< int &, F >(), " call throws" );
118+ static_assert ( is_nt_invocable_r< long &, CF >(), " " );
119+ static_assert ( ! is_nt_invocable_r< T, F >(), " call throws" );
120+ static_assert ( ! is_nt_invocable_r< NT, F >(), " call throws" );
121+ static_assert ( ! is_nt_invocable_r< Ex, F >(), " call throws" );
122+ static_assert ( ! is_nt_invocable_r< T, CF >(), " conversion throws" );
123+ static_assert ( is_nt_invocable_r< NT, CF >(), " " );
124+ static_assert ( ! is_nt_invocable_r< Ex, CF >(), " conversion fails" );
125+
126+ static_assert ( ! is_nt_invocable< F, int >(), " call throws" );
127+ static_assert ( is_nt_invocable< F&, int >(), " " );
128+
129+ static_assert ( ! is_nt_invocable_r< short &, F, int >(),
130+ " call throws" );
131+ static_assert ( is_nt_invocable_r< char &, F&, int >(), " " );
132+ static_assert ( ! is_nt_invocable_r< T, F&, int >(),
133+ " conversion throws" );
134+ static_assert ( is_nt_invocable_r< NT, F&, int >(), " " );
135+ static_assert ( ! is_nt_invocable_r< Ex, F&, int >(),
136+ " conversion fails, would use explicit constructor" );
137+
138+ static_assert ( is_nt_invocable< CF, int >(), " " );
139+ static_assert ( is_nt_invocable< CF&, int >(), " " );
140+
141+ static_assert ( is_nt_invocable_r< char &, CF, int >(), " " );
142+ static_assert ( is_nt_invocable_r< char &, CF&, int >(), " " );
143+
144+ static_assert ( ! is_nt_invocable_r< T, CF&, int >(),
145+ " conversion throws" );
146+ static_assert ( is_nt_invocable_r< NT, CF&, int >(), " " );
147+ static_assert ( ! is_nt_invocable_r< Ex, CF&, int >(),
148+ " conversion fails, would use explicit constructor" );
149+
150+ static_assert ( ! is_nt_invocable< F, int , int >(),
151+ " would call private member" );
152+ static_assert ( ! is_nt_invocable_r<void , F, int , int >(),
153+ " would call private member" );
100154}
0 commit comments