A
Alf P. Steinbach
I have code essentially equivalent to the inheritance below:
<code>
#include <iostream>
using namespace std;
class Base
{
public:
void foo() { cout << "Non-const foo" << endl; }
void foo() const { cout << "Const foo" << endl; }
};
template< class T >
class Derived: public T
{
public:
using T::foo;
void m() { foo(); }
};
int main()
{
Derived< Base const>().m();
}
</code>
Seems to work nicely, as if just ignoring the const qualification, and Comeau
doesn't complain (Comeau is usually right about such things).
But I can't find anything in the standard supporting it, and indeed when T is
not a template parameter but a typedef for 'Base const' then g++ rejects it.
So, is the above standard-conforming code or does it (at least formally) need to
"deconstify" the template parameter?
Cheers,
- Alf
<code>
#include <iostream>
using namespace std;
class Base
{
public:
void foo() { cout << "Non-const foo" << endl; }
void foo() const { cout << "Const foo" << endl; }
};
template< class T >
class Derived: public T
{
public:
using T::foo;
void m() { foo(); }
};
int main()
{
Derived< Base const>().m();
}
</code>
Seems to work nicely, as if just ignoring the const qualification, and Comeau
doesn't complain (Comeau is usually right about such things).
But I can't find anything in the standard supporting it, and indeed when T is
not a template parameter but a typedef for 'Base const' then g++ rejects it.
So, is the above standard-conforming code or does it (at least formally) need to
"deconstify" the template parameter?
Cheers,
- Alf