K
Knut Stolze
Hi,
Let's assume I have a namespace that contains a class definition. Now I would like to add a template specialization for std::numeric_limits for the new class. I want to have this specialization inside the scope of the namespace. Is there any way how I can "leave" or "unnest" the namespace NS so that I can have the declaration inside the "std" namespace instead of NS::std.
#include <iostream>
#include <limits>
namespace NS {
class ID {
public:
ID() : mValue(0) { }
ID(int value) : mValue(value) { }
private:
int mValue;
};
// this is what should be in ::std but not in NS::std
// namespace std {
// template<>
// struct numeric_limits<NS::ID> : public numeric_limits<int> { };
// }
}
Is there a way to achieve this?
For background information: the class is actually defined via a macro. I am using this to have different types of IDs that cannot be compared/assigned with each other (which would be possible with a regular typedef).
Let's assume I have a namespace that contains a class definition. Now I would like to add a template specialization for std::numeric_limits for the new class. I want to have this specialization inside the scope of the namespace. Is there any way how I can "leave" or "unnest" the namespace NS so that I can have the declaration inside the "std" namespace instead of NS::std.
#include <iostream>
#include <limits>
namespace NS {
class ID {
public:
ID() : mValue(0) { }
ID(int value) : mValue(value) { }
private:
int mValue;
};
// this is what should be in ::std but not in NS::std
// namespace std {
// template<>
// struct numeric_limits<NS::ID> : public numeric_limits<int> { };
// }
}
Is there a way to achieve this?
For background information: the class is actually defined via a macro. I am using this to have different types of IDs that cannot be compared/assigned with each other (which would be possible with a regular typedef).