2015-12-28 11:58 GMT+01:00 dariomt <dariomt@gmail.com>:
Piotr Kowalski <koval.gnu <at> gmail.com> writes:

>
>
> Are you using solaris studio 12.3 or older?Before version 12.4 there
was a bug where partial specialization for templates with same name but
in different namespaces (basic_string in std:: and boost::container:: in
this case) was considered ambiguous.
> A workaround for this problem (I would recommend using solaris studio
12.4) can be found here: https://community.oracle.com/thread/3706125
>
>

Thanks for the info and the link!

It seems to be 12.1
$ CC -V
CC: Sun C++ 5.10 SunOS_i386 Patch 128229-32 2013/12/04

It's not easy to change the compiler, it might not be possible *at all*
for this specific project.

I know what that means, we have similar problems in our project which is why I had investigated this specialization bug and found a workaround.
 
For now I'll #ifdef out the specializations for
boost::container::basic_string.

This is ok if you are not going to use boost::container in your project.

In the link from Oracle forum you can find a discussion on how to have all specializations available while keeping CC happy.

The more general solution (required if you want to have an official Boost patch) which worked for me with Boost 1.57.0 involved changing 2 files:
1. boost/config/compiler/sunpro_cc.hpp (put this at the end of file)
#if __SUNPRO_CC < 0x5130
// C++ up till 12.3 has a bug when partial specialization is for a template that only differs in namespace
// (like std::basic_string and boost::container::basic_string)
#define BOOST_DETAIL_SUNPRO_PARTIAL_SPEC_IN_DIFFERENT_NS_BUG 1
namespace boost {
namespace detail {
namespace sunpro_cc_aux {
template<typename, template<template<typename> class> class, typename D>
call_partial_spec_templ1: D {
};

template<typename A, template<typename> class T, template<template<typename> class> class C, typename D>
call_partial_spec_templ1<T<A>, C, D>: C<T> {
};

template<typename, template<template<typename, typename> class> class, typename D>
call_partial_spec_templ2: D {
};

template<typename A1, typename A2, template<typename, typename> class T, template<template<typename, typename> class> class C, typename D>
call_partial_spec_templ2<T<A1, A2>, C, D>: C<T> {
};

template<typename, template<template<typename, typename, typename> class> class, typename D>
call_partial_spec_templ3: D {
};

template<typename A1, typename A2, typename A3, template<typename, typename, typename> class T, template<template<typename, typename, typename> class> class C, typename D>
call_partial_spec_templ3<T<A1, A2, A3>, C, D>: C<T> {
};
}
}
}
#else
#undef BOOST_DETAIL_SUNPRO_PARTIAL_SPEC_IN_DIFFERENT_NS_BUG
#endif

2. boost/lexical_cast/tr_lexical_convert.hpp (replace is_stdstring definition and specializations with the following)

#ifdef BOOST_DETAIL_SUNPRO_PARTIAL_SPEC_IN_DIFFERENT_NS_BUG
        namespace sunpro_cc_aux
        {
            template<template<typename, typename, typename> class>
            struct is_stdstring: boost::false_type
            {};
        }

        template<typename T>
        struct is_stdstring: sunpro_cc_aux::call_partial_spec_templ3<T, sunpro_cc_aux::is_stdstring, boost::false_type>
        {};
# define BOOST_IS_STDSTRING_PARTIAL_SPEC(type) \
        template<> struct sunpro_cc_aux::is_stdstring<type>
#else
        template<typename T>
        struct is_stdstring
            : boost::false_type
        {};
# define BOOST_IS_STDSTRING_PARTIAL_SPEC(type) \
        template<typename CharT, typename Traits, typename Alloc>
        struct is_stdstring< type<CharT, Traits, Alloc> >
#endif

        BOOST_IS_STDSTRING_PARTIAL_SPEC(std::basic_string)
            : boost::true_type
        {};

        BOOST_IS_STDSTRING_PARTIAL_SPEC(boost::container::basic_string)
            : boost::true_type
        {};

Probably the templates call_partial_spec_templ1 and call_partial_spec_templ2 can be omitted, I added them for sake of completness.

Is there a way to get this solution into an official boost release?

Probably it should first be reported as a bug to get a number. This is a question to the Boost developers - I am not one, I am just a Boost user capable of fixing Sun C++-related bugs for my project. I am also too lazy to investigate Boost development process myself

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users