mirror of
https://github.com/boostorg/core.git
synced 2026-05-07 00:46:44 +02:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a90a31934f | |||
| f3cae495d3 | |||
| 8c338d5a65 |
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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 <boost/is_placeholder.hpp>]
|
||||
|
||||
The header `<boost/is_placeholder.hpp>` defines the class template
|
||||
`boost::is_placeholder<T>`. 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<class T> struct is_placeholder;
|
||||
}
|
||||
``
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Example]
|
||||
|
||||
``
|
||||
#include <boost/is_placeholder.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
struct arg1_type {};
|
||||
constexpr arg1_type arg1{};
|
||||
|
||||
template<> struct boost::is_placeholder<arg1_type>
|
||||
{
|
||||
static constexpr int value = 1;
|
||||
};
|
||||
|
||||
int f( int x ) { return x + 1; }
|
||||
|
||||
int main()
|
||||
{
|
||||
return boost::bind( f, arg1 )( -1 );
|
||||
}
|
||||
``
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef BOOST_IS_PLACEHOLDER_HPP_INCLUDED
|
||||
#define BOOST_IS_PLACEHOLDER_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined( _MSC_VER ) && ( _MSC_VER >= 1020 )
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
|
||||
// is_placeholder.hpp - TR1 is_placeholder metafunction
|
||||
//
|
||||
// Copyright (c) 2006 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template< class T > struct is_placeholder
|
||||
{
|
||||
enum _vt { value = 0 };
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_IS_PLACEHOLDER_HPP_INCLUDED
|
||||
+1
-1
@@ -6,7 +6,7 @@ include(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
|
||||
|
||||
if(HAVE_BOOST_TEST)
|
||||
|
||||
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::core Boost::static_assert Boost::type_traits)
|
||||
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::core Boost::config Boost::type_traits)
|
||||
|
||||
set(BOOST_TEST_LINK_LIBRARIES Boost::core Boost::throw_exception)
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ import testing ;
|
||||
|
||||
project : requirements
|
||||
<library>/boost/core//boost_core
|
||||
<library>/boost/static_assert//boost_static_assert
|
||||
<library>/boost/config//boost_config
|
||||
<library>/boost/type_traits//boost_type_traits
|
||||
<warnings>extra
|
||||
<toolset>msvc:<warnings-as-errors>on
|
||||
|
||||
Reference in New Issue
Block a user