Given:
namespace A {
class Foo;
class Bar;
}
namespace B {
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?
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.
No, templates can't be parametrized on a namespace.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With