language: C++11 (gcc-4.7.2)
date: 337 days 4 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Foo {
    int a;
public:
    Foo(int i) : a(i) {}
    template<typename T>
    auto foo() -> decltype(a) {
        return a;
    }
    auto foo() -> decltype(a) {
        return a;
    }
};
 
int main() {
    Foo f(0);
    f.foo(); // works fine
    f.foo<float>(); // error
}
prog.cpp: In function 'int main()':
prog.cpp:2:9: error: 'int Foo::a' is private
prog.cpp:17:18: error: within this context
prog.cpp:2:9: error: 'int Foo::a' is private
prog.cpp:17:18: error: within this context