| 1 |
// PR c++/93740 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
|
| 4 |
struct A { |
| 5 |
void foo(); |
| 6 |
void bar(); |
| 7 |
}; |
| 8 |
|
| 9 |
template<class T, T val> |
| 10 |
struct const_val { }; |
| 11 |
|
| 12 |
template<int N, class T> |
| 13 |
struct indexed_elem { }; |
| 14 |
|
| 15 |
using mem_fun_A_foo = const_val<decltype(&A::foo), &A::foo>; |
| 16 |
using mem_fun_A_bar = const_val<decltype(&A::bar), &A::bar>; |
| 17 |
|
| 18 |
struct A_indexed_member_funcs |
| 19 |
: indexed_elem<0, mem_fun_A_foo>, |
| 20 |
indexed_elem<1, mem_fun_A_bar> |
| 21 |
{ }; |
| 22 |
|
| 23 |
template<class T, int N> |
| 24 |
constexpr int index_of(indexed_elem<N, T>) { return N; } |
| 25 |
|
| 26 |
static_assert(index_of<mem_fun_A_foo>(A_indexed_member_funcs{}) == 0, ""); |
| 27 |
static_assert(index_of<mem_fun_A_bar>(A_indexed_member_funcs{}) == 1, ""); |