views:

181

answers:

3

I've seen two recent answers using _1 as a pure C++0x solution (no explicit mention of boost lambdas).

Is there such an animal as std::_1 I would think that having native lambdas will make such a construct redundant.

A Google code search for std::_1 brings two results from the same project so that's inconclusive.

+4  A: 

Apparently they are part of C++ 0x and should be defined in the <functional> header in a conformant compiler, see the following FAQ:

C++ 0x FAQ

Michael Goldshteyn
+8  A: 

Yes, they are part of C++0x inside the std::placeholders namespace, from the latest draft (n3126) §20.8.10.1.3 "Placeholders":

namespace std {
   namespace placeholders {
      // M is the implementation-defined number of placeholders
      extern unspecified _1;
      extern unspecified _2;
        .
        .
        .
      extern unspecified _M;
   }
}

They are actually included in TR1 (n1836 §3.6.4; n1455) along with bind, which are taken from the Boost.Bind library.

KennyTM
+4  A: 

Yes, they are part of C++0x. I haven't double-checked the TR1 specs, but I suspect they were added there (TR1 was essentially a library-only extension to C++03, so it couldn't rely on lambdas), and then, since it's already there in TR1, it'd be needlessly disruptive to remove it again in C++0x, even though it's no longer really necessary once you have true lambdas.

jalf
Placeholders are still necessary as C++0x lambdas aren't polymorphic.
usta