|
| 1 | +[/ |
| 2 | + Copyright 2014, 2025 Peter Dimov |
| 3 | + |
| 4 | + Distributed under the Boost Software License, Version 1.0. |
| 5 | + |
| 6 | + See accompanying file LICENSE_1_0.txt |
| 7 | + or copy at http://boost.org/LICENSE_1_0.txt |
| 8 | +] |
| 9 | + |
| 10 | +[section:is_placeholder is_placeholder] |
| 11 | + |
| 12 | +[simplesect Authors] |
| 13 | + |
| 14 | +* Peter Dimov |
| 15 | + |
| 16 | +[endsimplesect] |
| 17 | + |
| 18 | +[section Header <boost/is_placeholder.hpp>] |
| 19 | + |
| 20 | +The header `<boost/is_placeholder.hpp>` defines the class template |
| 21 | +`boost::is_placeholder<T>`. It defines a nested integral constant |
| 22 | +`value` which is `0` when `T` is not a `boost::bind` placeholder |
| 23 | +type, and a positive value corresponding to the placeholder index |
| 24 | +otherwise. |
| 25 | + |
| 26 | +That is, `is_placeholder<_1>::value` is `1`, |
| 27 | +`is_placeholder<_2>::value` is `2`, and so on. |
| 28 | + |
| 29 | +`is_placeholder` can be specialized for user types. If it is, |
| 30 | +`boost::bind` will recognize these types as placeholders. |
| 31 | + |
| 32 | +[section Synopsis] |
| 33 | + |
| 34 | +`` |
| 35 | +namespace boost |
| 36 | +{ |
| 37 | + template<class T> struct is_placeholder; |
| 38 | +} |
| 39 | +`` |
| 40 | + |
| 41 | +[endsect] |
| 42 | + |
| 43 | +[section Example] |
| 44 | + |
| 45 | +`` |
| 46 | +#include <boost/is_placeholder.hpp> |
| 47 | +#include <boost/bind.hpp> |
| 48 | + |
| 49 | +struct arg1_type {}; |
| 50 | +constexpr arg1_type arg1{}; |
| 51 | + |
| 52 | +template<> struct boost::is_placeholder<arg1_type> |
| 53 | +{ |
| 54 | + static constexpr int value = 1; |
| 55 | +}; |
| 56 | + |
| 57 | +int f( int x ) { return x + 1; } |
| 58 | + |
| 59 | +int main() |
| 60 | +{ |
| 61 | + return boost::bind( f, arg1 )( -1 ); |
| 62 | +} |
| 63 | +`` |
| 64 | + |
| 65 | +[endsect] |
| 66 | + |
| 67 | +[endsect] |
| 68 | + |
| 69 | +[endsect] |
0 commit comments