473,397 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

boost lambda question

Let m be of type vector<vector<int. I am trying to sort each
element of m:

for_each(m.begin(), m.end(), bind(sort, *_1.begin(), *_1.end());

This does not work:

'const struct
boost::lambda::lambda_functor<boost::lambda::place holder<1' has no
member named 'begin'

'const struct
boost::lambda::lambda_functor<boost::lambda::place holder<1' has no
member named 'end'

What do I do wrong?
Mar 11 '08 #1
1 2228
On Mar 11, 1:42 pm, nandor.sie...@gmail.com wrote:
Let m be of type vector<vector<int. I am trying to sort each
element of m:

for_each(m.begin(), m.end(), bind(sort, *_1.begin(), *_1.end());

This does not work:
Boost.Lambda does its magic by overloading operators. However, the
"dot" operator cannot be overloaded:
http://www.boost.org/doc/html/lambda...or_expressions
So, to create a lambda invoking a member function, you have to use
bind expressions:
http://www.boost.org/doc/html/lambda...nd_expressions
Which makes the expression less elegant : What you want to express as:
_1.begin()
becomes something like:
bind(&std::vector<int>::begin, _1)

HTH,
Éric Malenfant
Mar 11 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Toby Bradshaw | last post by:
Hi, Consider the following: class A { public: virtual bool foo() = 0; };
1
by: flopbucket | last post by:
Hi, After reading a bit about boost::lambda, I became curious how they implemented it. I downloaded it and had a look, but the all the headers and multiple templates make it a bit difficult to...
5
by: marius lazer | last post by:
I have an STL container of functors and I want to execute them using std::for_each. In the code snippet below the line marked "// good" works fine and the one marked "// nothing" compiles fine but...
3
by: baliga | last post by:
(std::cout << _1 << _2)("hello", 10); This does not work. If 2 parameters are string, it works. If any one or both parameters are integers, it does not work. But If I change it to ...
7
by: Henrique A. Menarin | last post by:
I want to create a function _and so that I could write vector<boolasserts; //... bool b = _and(asserts); and it "anded" all the elements in the vector. I implemented it like this:
3
by: rammel | last post by:
hi, can't I call member functions from an placeholder of a boost-like lambda expression? look on the example below please: -----------------------------------------------------------...
0
by: Barry Ding | last post by:
#include <map> #include <utility> #include <algorithm> #include <iostream> #include <list> #include <boost/lambda/lambda.hpp> #include <boost/lambda/bind.hpp> using namespace std;
1
by: Tim H | last post by:
Compiling with g++ 4: This line: if_then_else_return(_1 == 0, 64, _1) When called with a bignum class as an argument yields: /usr/include/boost/lambda/if.hpp: In member function 'RET...
3
by: Stuart Golodetz | last post by:
Hi, Just wondering why the following code doesn't work: #include <iostream> #include <boost/lambda/lambda.hpp> using namespace boost::lambda; int main()
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.