|
Boost Users : |
Subject: Re: [Boost-users] boost and std collisons in c++0x
From: dariomt (dariomt_at_[hidden])
Date: 2009-02-06 03:46:12
Sergey Sadovnikov <flex_ferrum <at> artberg.ru> writes:
>
> Perfectly! What you can say about following pieces of code:
>
> std::vector<std::shared_ptr<SomeClass>> vec;
> std::for_each(vec.begin(), vec.end(),
std::bind(&std::shared_ptr<SomeClass>::get, std::placeholders::_1,
std::bind(&SomeClass::foo, std::placeholders::_1, 10)));
>
> and
>
> vector<shared_ptr<SomeClass>> vec;
> for_each(vec.begin(), vec.end(), bind(&shared_ptr<SomeClass>::get, _1,
bind(&SomeClass::foo, _1, 10)));
>
What about scoped using directive (or using declaration)?
{ // begin code using namespaces
using namespace std;
using namespace std::placeholders;
vector<shared_ptr<SomeClass>> vec;
for_each(vec.begin(), vec.end(), bind(&shared_ptr<SomeClass>::get, _1,
bind(&SomeClass::foo, _1, 10)));
} // end code using namespaces
Explicit, readable, and doesn't affect code outside the braces
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