   Specialisation of template parameter as another template class.
  Hi.In a previous question (Templates, Namespaces, Linking.) I asked about explicit template specialisation for a unique class.However, I now need to use specialisation where the explicit parameter is itself a template class.Description:template class CZug<T> contains a function bam() that calls template function bar<T>().template function foo<T>() is declared but not defined except via specialisation.template function bar<T>(), by default calls template function foo<T>().but bar<T>(), when T = template class CMup<T>, does nothing, thus avoiding the need to define foo<CMup<T> >().Thus calling bam() on a CZug<CMup<int> > should compile.Unfortunately, I can't deduce the syntax for explicit specialisation using a template. Do I still use template <>?namespace a {    namespace b {   template <typename T> void foo(T item);    }}namespace a {    namespace c {   template <typename T> inline void bar(T item);    }}template <typename T>inline void a::c::bar(T item) {    a::b::foo(item);}namespace a {    template <typename T>    class CZug { public:   T m_item;   void bam();    };}template <typename T>void a::CZug<T>::bam() {    a::c::bar(m_item);}namespace a {    namespace d {   template <typename T>   class CMup {public:  T m_item;   };    }    namespace c {   //--------------------------------------------------------//   // THE PROBLEM IS HERE: YOU CAN POSSIBLY IGNORE THE REST. //   //--------------------------------------------------------//   //template <> // error: too many template-parameter-lists.   template <typename T>   //template <> // invalid explicit specialization before '>' token.   inline void bar(d::CMup<T> item);    }}// template <>.template <typename T>// template <>.inline void a::c::bar(a::d::CMup<T> item) { // <-- THIS FUNCTION SHOULD BE CALLED.    // Do Nothing.}// Test routine.int main() {    a::CZug<a::d::CMup<int> > test;    test.bam();}COMPILER ERROR: <code>void a::c::bar<a::d::CMup<int> >(a::d::CMup<int>*)]+0x11): undefined reference to `void a::b::foo<a::d::CMup<int> >(a::d::CMup<int>&)'</code>Any idea how I should write the declaration of void a::c::bar(d::CMup<T> item)??NOTE: Again with the namespaces: These exist in the code I am writing (with different names of course). But if I remove them on the test code it compiles fine.ENVIRONMENT: Compiled using "GNU GCC Compiler" from "Code::Blocks" on Ubuntu (Breezy Badger) Linux, AMD64 version.Thanks for all assistance.   
  Seems like an instantiation issue due to having CZug's implementation before the partial specialization you want it to use.  This was discovered by accident simply simplifying your code to get rid of this gawdy "namespace a { ... } namespace a { ... } namespace a { ... }" junk.Observe that commenting out the "#define DO_SPECIAL_AFTER" line will cause this code to work correctly (note: I have placed spaces after the backslashes to prevent the source tags from eating them up - remove the spaces to compile!):#define SPECIAL_STUFF \ template <typename T> \ inline void bar(d::CMup<T> item);    \ template <typename T> \ inline void bar(a::d::CMup<T> item) {}#define DO_SPECIAL_AFTERnamespace a {namespace b {template <typename T> void foo(T item);}namespace d {template <typename T>class CMup {public:T m_item;};}namespace c {template <typename T> inline void bar(T item);template <typename T>inline void bar(T item) {    a::b::foo(item);}#ifndef DO_SPECIAL_AFTERSPECIAL_STUFF#endif}template <typename T>class CZug {public:T m_item;void bam();};template <typename T>void CZug<T>::bam() {a::c::bar(m_item);}namespace c {#ifdef DO_SPECIAL_AFTERSPECIAL_STUFF#endif    }}// Test routine.int main() {    a::CZug<a::d::CMup<int> > test;    test.bam();};  Thanks.Seems odd, I reckon you should be able to do this properly somehow.I just decided to make CMup non-template and use a cast. Might look back later and see if I can fix it.