From f3cae495d325c654dd01883d83b0c5b8abb64a70 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 2 Jan 2026 13:40:47 +0200 Subject: [PATCH] Document is_placeholder --- doc/changes.qbk | 6 ++++ doc/core.qbk | 1 + doc/is_placeholder.qbk | 69 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 doc/is_placeholder.qbk diff --git a/doc/changes.qbk b/doc/changes.qbk index d2acc4b..53a3f60 100644 --- a/doc/changes.qbk +++ b/doc/changes.qbk @@ -7,6 +7,12 @@ [section Revision History] +[section Changes in 1.91.0] + +* The header [link core.is_placeholder `boost/is_placeholder.hpp`] has been moved from Bind to Core. ([github_issue 90]) + +[endsect] + [section Changes in 1.90.0] * The implementation of `BOOST_TEST_THROWS` and `BOOST_TEST_NO_THROW` macros defined in diff --git a/doc/core.qbk b/doc/core.qbk index 2ec1b3f..666736d 100644 --- a/doc/core.qbk +++ b/doc/core.qbk @@ -61,6 +61,7 @@ criteria for inclusion is that the utility component be: [include functor.qbk] [include identity.qbk] [include ignore_unused.qbk] +[include is_placeholder.qbk] [include is_same.qbk] [include launder.qbk] [include lightweight_test.qbk] diff --git a/doc/is_placeholder.qbk b/doc/is_placeholder.qbk new file mode 100644 index 0000000..7e991a6 --- /dev/null +++ b/doc/is_placeholder.qbk @@ -0,0 +1,69 @@ +[/ + Copyright 2014, 2025 Peter Dimov + + Distributed under the Boost Software License, Version 1.0. + + See accompanying file LICENSE_1_0.txt + or copy at http://boost.org/LICENSE_1_0.txt +] + +[section:is_placeholder is_placeholder] + +[simplesect Authors] + +* Peter Dimov + +[endsimplesect] + +[section Header ] + +The header `` defines the class template +`boost::is_placeholder`. It defines a nested integral constant +`value` which is `0` when `T` is not a `boost::bind` placeholder +type, and a positive value corresponding to the placeholder index +otherwise. + +That is, `is_placeholder<_1>::value` is `1`, +`is_placeholder<_2>::value` is `2`, and so on. + +`is_placeholder` can be specialized for user types. If it is, +`boost::bind` will recognize these types as placeholders. + +[section Synopsis] + +`` +namespace boost +{ + template struct is_placeholder; +} +`` + +[endsect] + +[section Example] + +`` +#include +#include + +struct arg1_type {}; +constexpr arg1_type arg1{}; + +template<> struct boost::is_placeholder +{ + static constexpr int value = 1; +}; + +int f( int x ) { return x + 1; } + +int main() +{ + return boost::bind( f, arg1 )( -1 ); +} +`` + +[endsect] + +[endsect] + +[endsect]