* pt.c (deduction_tsubst_fntype): Just suppress access checking.
[official-gcc.git] / gcc / testsuite / g++.dg / template / sfinae6_neg.C
blobc238222af75c388d4185bb21724c77cb697a9def
1 // DR 339
2 //
3 // Test of the use of the function call operator with SFINAE
4 typedef char yes_type;
5 struct no_type { char data[2]; };
7 template<typename T> T create_a();
9 template<typename T> struct type { };
11 template<bool, typename T = void> struct enable_if { typedef T type; };
12 template<typename T> struct enable_if<false, T> { };
14 template<typename F, typename T1, typename T2>
15   typename enable_if<sizeof(create_a<F>()(create_a<T1>(), create_a<T2>()), 1),
16                      yes_type>::type
17   check_is_callable2(type<F>, type<T1>, type<T2>);
19 no_type check_is_callable2(...);
21 template<typename F, typename T1, typename T2 = T1>
22 struct is_callable2
24   static const bool value = // { dg-error "within this context" }
25     (sizeof(check_is_callable2(type<F>(), type<T1>(), type<T2>()))
26      == sizeof(yes_type));
29 #define JOIN( X, Y ) DO_JOIN( X, Y )
30 #define DO_JOIN( X, Y ) DO_JOIN2(X,Y)
31 #define DO_JOIN2( X, Y ) X##Y
33 #ifdef __GXX_EXPERIMENTAL_CXX0X__
34 #  define STATIC_ASSERT(Expr) static_assert(Expr, #Expr)
35 #else
36 #  define STATIC_ASSERT(Expr) int JOIN(a,__LINE__)[Expr? 1 : -1]
37 #endif
40 struct A;
41 struct B;
43 struct A {
44   A(B);
47 struct B {
48   B(A);
51 struct F {
52   void operator()(A, A);
54 private:
55   void operator()(B, B); // { dg-error "is private" }
58 STATIC_ASSERT((is_callable2<F, B, B>::value));