OSDN Git Service

PR c++/51186
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / cpp0x / constexpr-ptrmem.C
1 // { dg-options -std=c++0x }
2
3 struct C { // literal type
4   int m;
5   int n;
6   constexpr C(int m) : m(m), n(-m) {}
7   constexpr bool is_neg() { return m < 0; }
8 };
9
10 constexpr bool check1(const C& c, int C:: *pm) { return c.*pm < 0; } // #1
11
12 constexpr bool check2(const C* pc, bool (C::*pm)() const) { return
13 (pc->*pm)(); } // #2
14
15 constexpr C c(-1);
16
17 static_assert(!check1(c, &C::n), "Error");
18 static_assert(check1(c, &C::m), "Error");
19
20 static_assert(check2(&c, &C::is_neg), "Error");