template class specialization in namespace?

Started by
0 comments, last by bilsa 19 years, 11 months ago
Hello! I was thinking about this: 1. a namespace containing a template function

namespace TEST_NAMESPACE {
	template <class T>
	bool is_true() {
		return 0;
	};
};
 
2. adding to the namespace works fine: (I specialize the template function)

namespace TEST_NAMESPACE {
	template <>
	bool is_true<SomeClass>() {
		return 0;
	};
};
 
3. adding to a namespace from a class doesn''t seem to work

template <class T>
class ClassToEditTEST_NAMESPACE {
public:
	namespace TEST_NAMESPACE {
		template <>
		bool is_true<T>() {
			return 1;
		}
	};
};
 
So, Is there any way of adding to TEST_NAMESPACE from within the class ClassToEditTEST_NAMESPACE ? thank you !
Advertisement
No. Namespaces are toplevel entities.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

This topic is closed to new replies.

Advertisement