I don’t know if this is possible at all, but I would like to achieve this: in the template class, I would like to use the namespace of the template parameter.
eg.
template<class P>
class Foo
{
public:
Foo();
virtual ~Foo();
void doSomething(P&);
void doSomethingElse();
protected:
void method1(namespace1::Type1&);
...
void methodN(namespace1::TypeN&);
}
using namespace namespace1;
template<class P>
void Foo<P>::doSomething(P& parameter)
{
...
Type1 type1 = P.getType1();
method1(type1);
...
}
template<class P>
void Foo<P>::doSomethingElse()
{
...
TypeN typen;
...
}
...
Of course, I do not want to specialize the template and provide a dedicated implementation for each possible value P, and I would also like to avoid passing all types, such as Type1and TypeN, as template parameters, since I have a lot of them.
Is it possible?
The project is based on C ++ 3, any solution for speeding up is welcome.
Update
Being a template parameter P, like any parameter TypeN, this may be the right approach:
template<typename NAMESPACE>
class Foo
{
typedef typename NAMESPACE::Parameter MyParameter;
typedef typename NAMESPACE::Type1 MyType1;
typedef typename NAMESPACE::Type1 MyTypeN;
...
}
source
share