#include <iostream>
#include <vector>
#include <boost/shared_ptr.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
using namespace std;
using namespace boost;
using namespace lambda;
struct B {
explicit B(int a) : a_(a) {}
int get_a() const { return a_; }
private:
int a_;
};
ostream& operator << (ostream &s, const B &b)
{
s << b.get_a();
return s;
}
int main()
{
shared_ptr<B> b1(new B(10));
shared_ptr<B> b2(new B(5));
vector<shared_ptr<B> > v;
v.push_back(b1);
v.push_back(b2);
for_each(v.begin(),v.end(), cout << *_1 << ' ');
cout << endl;
cout << count_if( v.begin(), v.end(), bind(&B::get_a, *_1) > 7);
return(0);
}
Sometimes you need lambda::bind()
-
Progress on my Google+ and LJ backups
Since Google is going to shut down Google+, I decided it was time to really make a home for my LiveJournal backup and my Google+ backup. Working…
-
Getting Shit Done
I came across an old LifeHacker article Get Shit Done Blocks Distracting Web Sites So You Can Do As the Name Instructs, that mentions a productivity…
-
Happy Birthday, Me. I got you data portability!
My list of addresses has made its way from a physical address book, to a Palm Pilot, to Microsoft Outlook, to Google Contacts to the iPhone Contacts…
- Post a new comment
- 3 comments
- Post a new comment
- 3 comments