
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The compilation errors are quite strange. For one thing, the compiler is complaining that names of members of various classes in <sstream> cannot be found. The code works against boost 1.32.0 and even against 1.33.0 with a (slightly modified) type traits folder from 1.32.0, but fails against the full 1.33.0. I suspect that something changed with the current release of the is_enum implementation that made the snippet below unhappy on VC 7.1. I have been spending a good deal of time trying to get to the bottom of this, so thanks for your interest. The intent of the code is to SFINAE-conditionally provide a family of operators for enums. In any case, here are two sample error messages (_Mystate is a member of basic_stringbuf) - Mat c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\sstream(267) : error C2065: '_Mystate' : undeclared identifier c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\sstream(265) : while compiling class-template member functi on 'void std::basic_stringbuf<_Elem,_Traits,_Alloc>::_Init(const _Elem *,size_t,std::basic_stringbuf<_Elem,_Traits,_Alloc>::_Strst ate)' with [ _Elem=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char> ] c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\sstream(503) : see reference to class template instantiatio n 'std::basic_stringbuf<_Elem,_Traits,_Alloc>' being compiled with [ _Elem=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char> ] adobe\future\widgets\headers\report_exception.hpp(56) : see reference to class template instantiation 'std::basic_stringst ream<_Elem,_Traits,_Alloc>' being compiled with [ _Elem=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char> ] Followed by this and others: third_party\boost_tp\boost\boost\type_traits\is_convertible.hpp(202) : error C2668: 'boost::detail::is_convertible_basic_impl<From ,To>::_m_check' : ambiguous call to overloaded function with [ From=boost::detail::is_convertible_impl<boost::add_reference<'unknown-type'>::type ,boost::detail::int_convertible>::r ef_type, To=boost::detail::int_convertible ] third_party\boost_tp\boost\boost\type_traits\is_convertible.hpp(199): could be 'boost::type_traits::yes_type boost::detail ::is_convertible_basic_impl<From,To>::_m_check(To)' with [ From=boost::detail::is_convertible_impl<boost::add_reference<'unknown-type'>::type ,boost::detail::int_convertible>::r ef_type, To=boost::detail::int_convertible ] third_party\boost_tp\boost\boost\type_traits\is_convertible.hpp(198): or 'boost::type_traits::no_type boost::detail: :is_convertible_basic_impl<From,To>::_m_check(...)' with [ From=boost::detail::is_convertible_impl<boost::add_reference<'unknown-type'>::type ,boost::detail::int_convertible>::r ef_type, To=boost::detail::int_convertible ] while trying to match the argument list '('unknown-type')' third_party\boost_tp\boost\boost\type_traits\is_convertible.hpp(228) : see reference to class template instantiation 'boos t::detail::is_convertible_basic_impl<From,To>' being compiled with [ From=boost::detail::is_convertible_impl<boost::add_reference<'unknown-type'>::type ,boost::detail::int_convertible>::r ef_type, To=boost::detail::int_convertible ] third_party\boost_tp\boost\boost\type_traits\is_convertible.hpp(302) : see reference to class template instantiation 'boos t::detail::is_convertible_impl<From,To>' being compiled with [ From=boost::add_reference<'unknown-type'>::type , To=boost::detail::int_convertible ] third_party\boost_tp\boost\boost\type_traits\is_convertible.hpp(348) : see reference to class template instantiation 'boos t::detail::is_convertible_impl_dispatch<From,To>' being compiled with [ From=boost::add_reference<'unknown-type'>::type , To=boost::detail::int_convertible ] third_party\boost_tp\boost\boost\type_traits\is_enum.hpp(96) : see reference to class template instantiation 'boost::is_co nvertible<From,To>' being compiled with [ From=boost::add_reference<'unknown-type'>::type, To=boost::detail::int_convertible ] third_party\boost_tp\boost\boost\type_traits\is_enum.hpp(153) : see reference to class template instantiation 'boost::deta il::is_enum_helper<false>::type<T>' being compiled with [ T='unknown-type' ] third_party\boost_tp\boost\boost\type_traits\is_enum.hpp(166) : see reference to class template instantiation 'boost::deta il::is_enum_impl<T>' being compiled with [ T='unknown-type' ] third_party\boost_tp\boost\boost\utility\enable_if.hpp(36) : see reference to class template instantiation 'boost::is_enum <T>' being compiled with [ T='unknown-type' ] c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\sstream(270) : see reference to class template instantiatio n 'boost::enable_if<Cond,T>' being compiled with [ Cond=boost::is_enum<'unknown-type'>, T='unknown-type' ] - --On Tuesday, August 16, 2005 8:15 AM -0700 Mat Marcus <mat-boost@emarcus.org> wrote:
In one of our projects, the following code produces some strange compilation errors under VC 7.1/boost 1.33.0. Can anyone suggest a workaround?
- Mat
# include <sstream> # include "boost/type_traits.hpp" # include "boost/utility/enable_if.hpp"
template <typename EnumType> typename boost::enable_if<boost::is_enum<EnumType>, EnumType>::type operator ~ (EnumType a);
std::stringstream t;
-----BEGIN PGP SIGNATURE----- Version: PGP Desktop 9.0.2 (Build 2424) iQA/AwUBQwJpJhIZBaoznf65EQLdKgCePdeYTVgqANiGGuW8jGppwysXiCYAnicY XsMT5MvoBIb4UVIrE+Fx7jk9 =sPBa -----END PGP SIGNATURE-----