]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | ||
50 | struct _a : placeholder {}; | |
51 | struct _b : placeholder {}; | |
52 | struct _c : placeholder {}; | |
53 | struct _d : placeholder {}; | |
54 | struct _e : placeholder {}; | |
55 | struct _f : placeholder {}; | |
56 | struct _g : placeholder {}; | |
57 | ||
58 | /** | |
59 | * \brief The default placeholder | |
60 | * | |
61 | * @ref _self is the default @ref placeholder used | |
62 | * by @ref any. It should be used as a default | |
63 | * by most concepts, so using concepts with no | |
64 | * explicit arguments will "just work" as much as | |
65 | * possible. | |
66 | */ | |
67 | struct _self : placeholder {}; | |
68 | ||
69 | } | |
70 | } | |
71 | ||
72 | #endif |