Solaris Studio 12.3 compiler fails with partial specialization for template classes with the same name in different namespaces.
namespace ns1 {
template<typename T> struct a {};
}
namespace ns2 {
template<typename T> struct a {};
}
template<typename T>
struct is_a { static const bool value = false; };
template<typename T>
struct is_a< ns1::a<T> > { static const bool value = true; };
#ifndef NO_NS2
template<typename T>
struct is_a< ns2::a<T> > { static const bool value = true; };
#endif
template<bool>
struct enable_if {};
template<>
struct enable_if<true> { typedef void type; };
template<typename T>
typename enable_if<is_a<T>::value>::type
fun(const T&)
{
}
void a()
{
fun(ns1::a<int>());
fun(ns2::a<char>());
}
Compiling above code gives errors:
Error: Could not find a match for fun<T>(ns1::a<int>) needed in a().
Error: Could not find a match for fun<T>(ns2::a<char>) needed in a().
What is more, compiling with -DNO_NS2 (so that specialization for ns2::a gets #ifdef'ed) produces no errors though there should be no match for fun<T>(ns2::a<char>)
I found this bug when trying to use Boost 1.57. In lexical_cast library, is_stdstring trait which fails because it has specializations for std::basic_string and boost::container::basic_string.