Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is _1 part of C++0x?

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.

like image 914
Motti Avatar asked Oct 24 '10 18:10

Motti


2 Answers

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.

like image 99
kennytm Avatar answered Oct 14 '22 17:10

kennytm


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.

like image 24
jalf Avatar answered Oct 14 '22 19:10

jalf