[Lambda] Compiler dependent error, can anyone explain?
Hi Peeps I have this cut down code example #include <vector> #include <map> #include <algorithm> #include <boost/shared_ptr.hpp> #include <boost/lambda/lambda.hpp> #include <boost/lambda/bind.hpp> template < typename Iter, typename Pred > bool any_of_if( Iter first, Iter last, Pred pred ) { return std :: find_if( first, last, pred ) != last; } struct A { }; bool fnOfA( const A & ); typedef std :: vector< boost :: shared_ptr< A > > VecOfPtr; typedef std :: map< int, VecOfPtr > MapOfVecOfPtr; bool contains_if( const VecOfPtr &, bool ( * pred )( const VecOfPtr :: value_type :: value_type &) ); bool f( const boost :: shared_ptr< MapOfVecOfPtr > & myMap ) { using namespace boost; return any_of_if( myMap -> begin( ), myMap -> end( ), lambda :: bind( contains_if, lambda :: bind( & MapOfVecOfPtr :: value_type :: second, lambda :: _1 ), fnOfA ) ); } This compiles under gcc (3.4.4), but under Vis Studio 2008 gives a huge error message, (attached), but summarised as boost\boost/tuple/detail/tuple_basic.hpp(439) : error C2664: 'boost::tuples::detail::non_storeable_type<T>::non_storeable_type(const boost::tuples::detail::non_storeable_type<T> &)' : cannot convert parameter 1 from 'bool (__cdecl &)(const A &)' to 'const boost::tuples::detail::non_storeable_type<T> &' It also goes away if I introduce a temporary local variable for fnOfA. Is this a know bug in VisStudio or Boost, possibly with a known solution? Thanks, - Rob.
AMDG Robert Jones wrote:
I have this cut down code example <snip>
This compiles under gcc (3.4.4), but under Vis Studio 2008 gives a huge error message, (attached), but summarised as
boost\boost/tuple/detail/tuple_basic.hpp(439) : error C2664: 'boost::tuples::detail::non_storeable_type<T>::non_storeable_type(const boost::tuples::detail::non_storeable_type<T> &)' : cannot convert parameter 1 from 'bool (__cdecl &)(const A &)' to 'const boost::tuples::detail::non_storeable_type<T> &'
It also goes away if I introduce a temporary local variable for fnOfA.
Probably because you used a bool(*)(const A&) instead of bool(&)(const A&)? Pointer to functions are generally better behaved than references to functions.
Is this a know bug in VisStudio or Boost, possibly with a known solution?
Whatever the problem was, it appears to be fixed in the trunk. It errors through 1.37, I never downloaded 1.38 or 1.39, so I didn't check them. My best guess is that it was fixed by https://svn.boost.org/trac/boost/changeset/51448#file3 In Christ, Steven Watanabe
participants (2)
-
Robert Jones
-
Steven Watanabe