
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 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/AwUBQwIDTxIZBaoznf65EQKEyACgnVW7095czvJp1MMvNruggOxQfIQAn2Qs TAtl4P353L4rRplTeFJwW2kO =jqlu -----END PGP SIGNATURE-----

Mat Marcus <mat-boost@emarcus.org> writes:
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?
Might be easier to guess if you show us the errors. -- Dave Abrahams Boost Consulting www.boost-consulting.com

-----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-----

"Mat Marcus" <mat-boost@emarcus.org> wrote in message news:6E14B33FF54058DC7BAE8CCF@ALEPH.adobe.com...
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
The compilation errors are quite strange.
Hi. Boosters, I'm not too sure about this particular error( However I'll bet its a Concept error... whatever... Its certainly an error in the library implementation),. This is an example of mislocation that often occurs in C++. (I often find the compiler outputs error messages fom standard libraries, only due to an error in my own code.). The XConcept Check and enable_if( and mpl) libraries could help with this, if the library developer has sufficient understanding, and if they are used. As it stands I dont believe that boost libraries take error checking adequately seriously. It would be useful if somebody picked up on error-checking in general and wrote a developers tutorial. I am confident that, with designed-in error checking for all boost libraries, the errors cited here( for instance) could be replaced with something much more useful. For degree students... a useful topic... so take this up, combining theory of programming with prcatical day-to-day (economic)coding. reagrds Andy Little

Mat, Mat Marcus wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
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);
I can't say whether that is your problem, but code like this is potentially dangerous. It'll break whenever you happen to "suck" in a use of operator~ on an unnamed enum. And yes it tends to generate weird error messages. Looking at the errors the unknown type in the is_enum instantiation looks suspicious to me. I only have apples gcc 4 currently. A slightly modified example gives this: enum { foo, bar }; template <typename EnumType> typename boost::enable_if<boost::is_enum<EnumType>, EnumType>::type operator ~ (EnumType a); int main() { int i = ~bar; std::stringstream t; } mat.cpp: In function 'int main()': mat.cpp:14: error: '<anonymous enum>' is/uses anonymous type mat.cpp:14: error: trying to instantiate 'template<class T> struct boost::is_enum' Thomas
std::stringstream t;
-----BEGIN PGP SIGNATURE----- Version: PGP Desktop 9.0.2 (Build 2424)
iQA/AwUBQwIDTxIZBaoznf65EQKEyACgnVW7095czvJp1MMvNruggOxQfIQAn2Qs TAtl4P353L4rRplTeFJwW2kO =jqlu -----END PGP SIGNATURE----- _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (4)
-
Andy Little
-
David Abrahams
-
Mat Marcus
-
Thomas Witt