Hello, dariomt.


Friday, February 6, 2009 at 1:02:30 AM Michael Fawcett wrote:


>> I mean what you can use unqualified ids and usings in most cases

>> without any errors from the compilator _when you use only standard

>> facilities_.


MF> True, but same with C++.  If you are only using std namespace, you

MF> have no problems.  It's only when you bring multiple namespaces into

MF> the same scope. e.g. System + XNA, or std + boost.

But I see some significant difference. Both std and boost are standard

libraries for most C++ programmers. One 'de-jure' and another

'de-facto'. In the near future both STL and boost will contain similar

set of most-useful entities. Unlike System and XNA.


Friday, February 6, 2009 at 11:46:12 AM dariomt wrote:


d> Sergey Sadovnikov <flex_ferrum <at> artberg.ru> writes:


d> What about scoped using directive (or using declaration)?



d> { // begin code using namespaces


d>    using namespace std;

d>    using namespace std::placeholders;

d>    vector<shared_ptr<SomeClass>> vec;

d>    for_each(vec.begin(), vec.end(),

d> bind(&shared_ptr<SomeClass>::get, _1,

d> bind(&SomeClass::foo, _1, 10)));


d> } // end code using namespaces



d> Explicit, readable, and doesn't affect code outside the braces

Just add 'using namespace boost' in this scope for some manner, and you could return

to the previous problem:


{ // begin code using namespaces


   using namespace std;

   using namespace std::placeholders;

   using namespace boost;

   std::vector<string> path_parts;

   split(vec, "/1/2/3/4", is_any_of("\\/") ); // string splitter from string algo

   for_each(path_parts.begin(), path_parts.end(), bind(&SomeClass::RegisterPathPart, _1)); // do something with string parts


} // end code using namespaces



-- 

Best Regards,

 Sergey                          mailto:flex_ferrum@artberg.ru