Piotr Kowalski
2015-12-28 11:58 GMT+01:00 dariomt
:Piotr
Are you using solaris studio 12.3 or older?Before version 12.4
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
Kowalski
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
class, typename D> call_partial_spec_templ1: D { }; template
class C, typename D> call_partial_spec_templ1 : C<T> { }; template
class> class, typename D> call_partial_spec_templ2: D { }; template
class T, template class> class C, typename D> call_partial_spec_templ2 , C, D>: C<T> { }; template
class> class, typename D> call_partial_spec_templ3: D { }; template
class T, template class> class C, typename D> call_partial_spec_templ3 , 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 class> struct is_stdstring: boost::false_type {}; }
template<typename T> struct is_stdstring: sunpro_cc_aux::call_partial_spec_templ3
{}; # 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 struct is_stdstring< type > #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
Thanks a lot for your thorough answer. Let's see if the maintainer chimes in. I have other problems with Boost 1.59.0 and SunCC 5.10 anyway (will report in another thread), so I'm not sure I'll be able to use this version :(