473,396 Members | 1,895 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,396 software developers and data experts.

boost::lambda::bind

#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>

using namespace std;
using namespace boost::lambda;

struct A {
A(int i) : i(i) {}
void print() const {
cout << "A::print: " << i << endl;
}
int i;
};

int main()
{
list<AList;
List.push_back(A(1));
List.push_back(A(2));
List.push_back(A(3));
List.push_back(A(4));
for_each(List.begin(), List.end(), cout << bind(&A::i, _1) << '
'); // works

map<char const*, intMap;
Map["hello"] = 10;
Map["world"] = 11;
for_each(Map.begin(), Map.end(),
cout << bind(&(pair<char const*, int>::first), _1)
//illegal reference to non-static member
//'std::pair<_Ty1,_Ty2>::first'
<< ' '
<< bind(&(pair<char const*, int>::second), _1)
);

return 0;
}

Jul 22 '07 #1
0 1763

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

Similar topics

3
by: Rafal Dabrowa | last post by:
Suppose I have the following structure: struct xy { int x, y; }; and the following vector: vector<xy> v(10); I want to use boost/lambda for find an item in the table. Let's say, with x...
6
by: Toby Bradshaw | last post by:
Hi, Consider the following: class A { public: virtual bool foo() = 0; };
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: Misiu | last post by:
Hello everybody, How to avoid using struct IsDataType for comparison for find_if algorithm but use something like that what is now commented out in the code below? Regards, Misiu ...
4
by: silverburgh.meryl | last post by:
I have code which uses Boost lambda in a template like this: using namespace boost::lambda; template<class T> bool lessThanXY( T& src, T& dest ) { return (src.getY() < dest.getY()); } ...
0
by: XHengDF | last post by:
I am a new gay to use the library boost, so i confused by some details! now, anybody could help me to explain the difference between boost::bind and boost::lambda::bind when i use the library. I...
4
by: yurec | last post by:
Hi I start learning boost.Today I tried to use boost::lambda but failed to compile very simple example. 2 hours of googling gave nothing. Can anybody help me? using namespace boost::lambda; ...
1
by: nandor.sieben | last post by:
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...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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,...

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.