summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/template/sfinae27.C
blob: 0ecd1700dec8b12cdfc6dc34faab65b0c7cc302e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Origin: PR c++/46162

struct small_type { char dummy; };
struct large_type { char dummy[2]; };

template<class T>
struct has_foo_member_variable
{
  template<int T::*> struct tester;
  template<class U> static small_type has_foo(tester<&U::foo> *);
  template<class U> static large_type has_foo(...);
  static const bool value = (sizeof(has_foo<T>(0)) == sizeof(small_type));
};

struct A
{
  static int foo()
  {
    return 0;
  }
};

struct B
{
  static int foo;
};

void
bar()
{
  bool b = has_foo_member_variable<A>::value;
}