summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/template/partial6.C
blob: 80bbfe3c138fd420b148754a60fd73d4cb3c7330 (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
// PR c++/41703
// The second GetAllSize template is more specialized because even though
// deduction on each parameter type succeeds, we never get a template
// argument for its X to make it match the first template.

template <typename T, int (T::*)() const>
struct TSizeEnabler
{
    typedef T TClass;
};

template <typename X>
int
GetAllSize(const X &Var)
{ return sizeof(Var); }

template <typename X>
int
GetAllSize(const typename TSizeEnabler<X, &X::func>::TClass &Var)
{ return Var.func(); }

struct H
{
    int func() const;
};

int main()
{
    H b;
    return GetAllSize< H >(b);
}