views:

49

answers:

2

Given:

namespace A {
  class Foo;
  class Bar;
}

namespace A {
  class Foo;
  class Bar;
}

I want to template a class on the namespace A or B such that the following works:

template<name> class C {
  name::Foo* foo;
  name::Bar* bar;
}

Can this be done directly or do I need to create a pair of struct types with typedefs in them?

+1  A: 

No, templates can't be parametrized on a namespace.

Matias Valdenegro
+1  A: 

You can't template on a namespace. If you're able to use a class (with most likely public attributes/static methods) then you can template on the class as a semi-workaround.

Mark B