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

Subversion Repositories openrisc

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

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 comma operator with SFINAE
4
 
5
// Boilerplate helpers
6
typedef char yes_type;
7
struct no_type { char data[2]; };
8
 
9
template T create_a();
10
template struct type { };
11
 
12
template struct enable_if { typedef T type; };
13
template struct enable_if { };
14
 
15
#define JOIN( X, Y ) DO_JOIN( X, Y )
16
#define DO_JOIN( X, Y ) DO_JOIN2(X,Y)
17
#define DO_JOIN2( X, Y ) X##Y
18
 
19
template
20
  typename enable_if<(sizeof(create_a(), create_a()) > 0),
21
                     yes_type>::type
22
  check_comma(int);
23
 
24
template no_type check_comma(...);
25
 
26
template
27
struct has_comma
28
{
29
  static const bool value =
30
    (sizeof(check_comma(0)) == sizeof(yes_type));
31
};
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
struct X { };
40
struct Y { };
41
struct Z { };
42
 
43
bool operator,(X&, Y);
44
bool operator,(X, Z);
45
void operator,(const Y&, const Z&);
46
 
47
STATIC_ASSERT((has_comma::value));
48
STATIC_ASSERT((has_comma::value));
49
STATIC_ASSERT((has_comma::value));
50
STATIC_ASSERT((has_comma::value));
51
STATIC_ASSERT((has_comma::value));
52
STATIC_ASSERT((has_comma::value));
53
STATIC_ASSERT((!has_comma::value));

powered by: WebSVN 2.1.0

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