Boost logo

Boost Users :

Subject: [Boost-users] Boost.Lambda: failure to compile with std::set, OK withstd::vector, bug?
From: Joost Kraaijeveld (J.Kraaijeveld_at_[hidden])
Date: 2009-01-04 06:34:09


Hi,

Compiling the code below with std::vector goes OK, the std::set variant does not compile:

/usr/include/boost/lambda/detail/actions.hpp no matching function for call to ‘boost::lambda::function_adaptor<void (Integer::*)()>::apply(void (Integer::* const&)(), const Integer&)’
/usr/include/boost/lambda/detail/actions.hpp return-statement with a value, in function returning 'void'
/usr/include/c++/4.3/bits/stl_tree.h invalid type argument of ‘unary *’

Is this a bug or am I doing something wrong (gcc (Debian 4.3.2-1) 4.3.2 / Boost 1.35) ?

#include <iostream>
#include <vector>
#include <set>
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/algorithm.hpp>
#include <boost/lambda/bind.hpp>

struct Integer
{
  Integer(int anInt) : integer(anInt){}
  bool operator<( const Integer& anInteger) const { return integer < anInteger.integer;}
  void print(){std::cout << integer << std::endl;}
  int integer;
};
int main(int argc, char* argv[])
{
// std::vector<Integer> collection(5,2);
  std::set<Integer> collection(5,2);

  // Calling a member function
  std::for_each(collection.begin(),
                collection.end(),
                boost::lambda::bind(&Integer::print, boost::lambda::_1));
}

TIA

-- 
Groeten,
Joost Kraaijeveld
Askesis B.V.
Molukkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: 024-3608416
web: www.askesis.nl

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