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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [g++.dg/] [template/] [sfinae4.C] - Blame information for rev 338

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 301 jeremybenn
// DR 339
2
//
3
// Test of the use of free functions with SFINAE
4
void foo(int) { }
5
template void foo(T*) { }
6
 
7
typedef char yes_type;
8
struct no_type { char data[2]; };
9
 
10
template T create_a();
11
 
12
template struct enable_if { typedef T type; };
13
template struct enable_if { };
14
 
15
template
16
  typename enable_if<(sizeof(foo(create_a()), 1) > 0),
17
                     yes_type>::type
18
  check_has_foo(const volatile T&);
19
 
20
no_type check_has_foo(...);
21
 
22
template
23
struct has_foo
24
{
25
  static const bool value =
26
    (sizeof(check_has_foo(create_a())) == sizeof(yes_type));
27
};
28
 
29
struct X { };
30
 
31
int a1[has_foo::value? 1 : -1];
32
int a2[has_foo::value? 1 : -1];
33
int a3[has_foo::value? 1 : -1];
34
int a4[has_foo::value? -1 : 1];
35
int a5[has_foo::value? -1 : 1];

powered by: WebSVN 2.1.0

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