Skip to content

Commit f3cae49

Browse files
committed
Document is_placeholder
1 parent 8c338d5 commit f3cae49

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

doc/changes.qbk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77

88
[section Revision History]
99

10+
[section Changes in 1.91.0]
11+
12+
* The header [link core.is_placeholder `boost/is_placeholder.hpp`] has been moved from Bind to Core. ([github_issue 90])
13+
14+
[endsect]
15+
1016
[section Changes in 1.90.0]
1117

1218
* The implementation of `BOOST_TEST_THROWS` and `BOOST_TEST_NO_THROW` macros defined in

doc/core.qbk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ criteria for inclusion is that the utility component be:
6161
[include functor.qbk]
6262
[include identity.qbk]
6363
[include ignore_unused.qbk]
64+
[include is_placeholder.qbk]
6465
[include is_same.qbk]
6566
[include launder.qbk]
6667
[include lightweight_test.qbk]

doc/is_placeholder.qbk

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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

Comments
 (0)