source:
downloads/boost_1_33_1/libs/mpl/doc/src/refmanual/Placeholders.rst
@
12
| Last change on this file since 12 was 12, checked in by landauf, 18 years ago | |
|---|---|
| File size: 2.1 KB | |
Placeholders
Synopsis
namespace placeholders {
typedef |unspecified| _;
typedef arg<1> _1;
typedef arg<2> _2;
|...|
typedef arg<n> _n;
}
using placeholders::_;
using placeholders::_1;
using placeholders::_2;
|...|
using placeholders::_n;
Description
A placeholder in a form _n is simply a synonym for the corresponding arg<n> specialization. The unnamed placeholder _ (underscore) carries `special meaning`__ in bind and lambda expressions, and does not have defined semantics outside of these contexts.
Placeholder names can be made available in the user namespace through using namespace mpl::placeholders; directive.
Header
#include <boost/mpl/placeholders.hpp>
|Note:| The include might be omitted when using placeholders to construct a |Lambda Expression| for passing it to MPL's own algorithm or metafunction: any library component that is documented to accept a lambda expression makes the placeholders implicitly available for the user code |-- end note|
Parameters
None.
Expression semantics
For any integral constant n in the range [1, |BOOST_MPL_LIMIT_METAFUNCTION_ARITY|] and arbitrary types |a1...an|:
typedef apply_wrapn<_n,a1,|...|an>::type x;
| Return type: | A type. |
|---|---|
| Semantics: | Equivalent to typedef apply_wrapn< arg<n>,a1,|...|an >::type x; |
Example
typedef apply_wrap5< _1,bool,char,short,int,long >::type t1; typedef apply_wrap5< _3,bool,char,short,int,long >::type t3; BOOST_MPL_ASSERT(( is_same< t1, bool > )); BOOST_MPL_ASSERT(( is_same< t3, short > ));
See also
|Composition and Argument Binding|, |arg|, |lambda|, |bind|, |apply|, |apply_wrap|










