Boost logo

Boost Users :

Subject: [Boost-users] [Lambda] Compiler dependent error, can anyone explain?
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2009-06-15 14:55:18


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.





Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net