OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [template/] [sfinae6.C] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// 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]; };
6
 
7
template T create_a();
8
 
9
template struct type { };
10
 
11
template struct enable_if { typedef T type; };
12
template struct enable_if { };
13
 
14
template
15
  typename enable_if()(create_a(), create_a()), 1),
16
                     yes_type>::type
17
  check_is_callable2(type, type, type);
18
 
19
no_type check_is_callable2(...);
20
 
21
template
22
struct is_callable2
23
{
24
  static const bool value =
25
    (sizeof(check_is_callable2(type(), type(), type()))
26
     == sizeof(yes_type));
27
};
28
 
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
32
 
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
38
 
39
 
40
struct A;
41
struct B;
42
 
43
struct A {
44
  A(B);
45
};
46
 
47
struct B {
48
  B(A);
49
};
50
 
51
struct F1 { };
52
 
53
struct F2 {
54
  bool operator()(int, float);
55
};
56
 
57
struct F3 {
58
  bool operator()(int);
59
};
60
 
61
struct F4 {
62
  void operator()(A, A);
63
  void operator()(B, B);
64
};
65
 
66
struct F5 {
67
  void operator()(A, A);
68
 
69
private:
70
  void operator()(B, B);
71
};
72
 
73
STATIC_ASSERT((is_callable2::value));
74
STATIC_ASSERT((!is_callable2::value));
75
STATIC_ASSERT((!is_callable2::value));
76
STATIC_ASSERT((is_callable2::value));
77
STATIC_ASSERT((!is_callable2::value));
78
STATIC_ASSERT((!is_callable2::value));
79
STATIC_ASSERT((is_callable2::value));
80
STATIC_ASSERT((is_callable2::value));
81
STATIC_ASSERT((!is_callable2::value));
82
STATIC_ASSERT((is_callable2::value));
83
STATIC_ASSERT((!is_callable2::value));

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.