Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Struct placeholder

boost::type_erasure::placeholder

Synopsis

// In header: <boost/type_erasure/placeholder.hpp>


struct placeholder {
};

Description

Placeholders are used heavily throughout the library. Every placeholder must derive from placeholder. The library provides a number of placeholders, out of the box, but you are welcome to define your own, if you want more descriptive names. The placeholder _self is special in that it is used as the default wherever possible.

What exactly is a placeholder? Placeholders act as a substitute for template parameters in concepts. The library automatically replaces all the placeholders used in a concept with the actual types involved when it stores an object in an any.

For example, in the following,

any<copy_constructible<_a>, _a> x(1);

The library sees that we're constructing an any that uses the _a placeholder with an int. Thus it binds _a to int and instantiates copy_constructible<int>.

When there are multiple placeholders involved, you will have to use tuple, or pass the bindings explicitly, but the substitution still works the same way.


PrevUpHomeNext