| 1 | // Boost.TypeErasure library |
| 2 | // |
| 3 | // Copyright 2011 Steven Watanabe |
| 4 | // |
| 5 | // Distributed under the Boost Software License Version 1.0. (See |
| 6 | // accompanying file LICENSE_1_0.txt or copy at |
| 7 | // http://www.boost.org/LICENSE_1_0.txt) |
| 8 | // |
| 9 | // $Id$ |
| 10 | |
| 11 | #ifndef BOOST_TYPE_ERASURE_PLACEHOLDERS_HPP_INCLUDED |
| 12 | #define BOOST_TYPE_ERASURE_PLACEHOLDERS_HPP_INCLUDED |
| 13 | |
| 14 | namespace boost { |
| 15 | namespace type_erasure { |
| 16 | |
| 17 | /** |
| 18 | * Placeholders are used heavily throughout the library. |
| 19 | * Every placeholder must derive from @ref placeholder. |
| 20 | * The library provides a number of placeholders, |
| 21 | * out of the box, but you are welcome to define your own, |
| 22 | * if you want more descriptive names. The placeholder |
| 23 | * @ref _self is special in that it is used as the default |
| 24 | * wherever possible. |
| 25 | * |
| 26 | * What exactly is a placeholder? Placeholders act as |
| 27 | * a substitute for template parameters in concepts. |
| 28 | * The library automatically replaces all the placeholders |
| 29 | * used in a concept with the actual types involved when |
| 30 | * it stores an object in an @ref any. |
| 31 | * |
| 32 | * For example, in the following, |
| 33 | * |
| 34 | * @code |
| 35 | * any<copy_constructible<_a>, _a> x(1); |
| 36 | * @endcode |
| 37 | * |
| 38 | * The library sees that we're constructing an @ref any |
| 39 | * that uses the @ref _a placeholder with an @c int. |
| 40 | * Thus it binds @ref _a to int and instantiates |
| 41 | * @ref copy_constructible "copy_constructible<int>". |
| 42 | * |
| 43 | * When there are multiple placeholders involved, you |
| 44 | * will have to use @ref tuple, or pass the bindings |
| 45 | * explicitly, but the substitution still works the |
| 46 | * same way. |
| 47 | */ |
| 48 | struct placeholder { |
| 49 | /// INTERNAL ONLY |
| 50 | typedef void _boost_type_erasure_is_placeholder; |
| 51 | }; |
| 52 | |
| 53 | struct _a : placeholder {}; |
| 54 | struct _b : placeholder {}; |
| 55 | struct _c : placeholder {}; |
| 56 | struct _d : placeholder {}; |
| 57 | struct _e : placeholder {}; |
| 58 | struct _f : placeholder {}; |
| 59 | struct _g : placeholder {}; |
| 60 | |
| 61 | /** |
| 62 | * \brief The default placeholder |
| 63 | * |
| 64 | * @ref _self is the default @ref placeholder used |
| 65 | * by @ref any. It should be used as a default |
| 66 | * by most concepts, so using concepts with no |
| 67 | * explicit arguments will "just work" as much as |
| 68 | * possible. |
| 69 | */ |
| 70 | struct _self : placeholder {}; |
| 71 | |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | #endif |
| 76 | |