Dear developpers,

My environment is
- GCC 4.3.2
- Debian 5.0 AMD 64
- compile option is none, I compiled testprogram is as follows
- g++ -o program-name source-file-name
- compiler outputs no error and warning

The template parameter which is declared in a class is hidden by
outer class member when the template parameter is used in the
class method.
see following code,
--------------------
#include <iostream>
using namespace std;
struct test
{
    const static int value = 1;
    template<int value> struct inner1 {
        const static int inner_value = value;
        int get_value() { return value; }
    };
};

int main()
{
    test::inner1<2> t1;
    cout << t1.inner_value << endl;
    cout << t1.get_value() << endl;
}
--------------------
The output is as follows
2
1

I think the outer variable name should not hide the inner template
parameter. Therefore, the correct output is as follows.
2
2

Best regards,
Toshihiko Ando.

Reply via email to