Tags in_place_init and in_place_init_if become inline constexpr

This commit is contained in:
Andrzej Krzemienski
2024-09-13 16:22:40 +02:00
parent 19f202b650
commit cbfb66379b
4 changed files with 8 additions and 7 deletions

View File

@ -16,10 +16,10 @@
namespace boost { namespace boost {
class in_place_init_t { /* see below */ } ; ``[link reference_in_place_init __GO_TO__]`` class in_place_init_t { /* see below */ } ; ``[link reference_in_place_init __GO_TO__]``
const in_place_init_t in_place_init ( /* see below */ ) ; inline constexpr in_place_init_t in_place_init ( /* see below */ ) ;
class in_place_init_if_t { /*see below*/ } ; ``[link reference_in_place_init_if __GO_TO__]`` class in_place_init_if_t { /*see below*/ } ; ``[link reference_in_place_init_if __GO_TO__]``
const in_place_init_if_t in_place_init_if ( /*see below*/ ) ; inline constexpr in_place_init_if_t in_place_init_if ( /*see below*/ ) ;
template <class T> template <class T>
class optional ; ``[link reference_operator_template __GO_TO__]`` class optional ; ``[link reference_operator_template __GO_TO__]``

View File

@ -17,6 +17,7 @@
* Dropped dependency on Boost.Utility. * Dropped dependency on Boost.Utility.
* Dropped dependency on Boost.Predef. * Dropped dependency on Boost.Predef.
* A bit faster implementation of some relational operations. * A bit faster implementation of some relational operations.
* Tags `in_place_init` and `in_place_init_if` become `inline constexpr` and therewith leave smaller footprint in the executable. This addresses [@https://github.com/boostorg/optional/issues/103 issue #103].
[heading Boost Release 1.85] [heading Boost Release 1.85]

View File

@ -50,7 +50,7 @@ namespace {
#else #else
BOOST_INLINE_VARIABLE BOOST_CONSTEXPR_OR_CONST none_t none ((none_t::init_tag())); BOOST_INLINE_CONSTEXPR none_t none ((none_t::init_tag()));
#endif // older definitions #endif // older definitions

View File

@ -103,17 +103,17 @@ namespace optional_ns {
struct in_place_init_t struct in_place_init_t
{ {
struct init_tag{}; struct init_tag{};
explicit in_place_init_t(init_tag){} BOOST_CONSTEXPR explicit in_place_init_t(init_tag){}
}; };
const in_place_init_t in_place_init ((in_place_init_t::init_tag())); BOOST_INLINE_CONSTEXPR in_place_init_t in_place_init ((in_place_init_t::init_tag()));
// a tag for conditional in-place initialization of contained value // a tag for conditional in-place initialization of contained value
struct in_place_init_if_t struct in_place_init_if_t
{ {
struct init_tag{}; struct init_tag{};
explicit in_place_init_if_t(init_tag){} BOOST_CONSTEXPR explicit in_place_init_if_t(init_tag){}
}; };
const in_place_init_if_t in_place_init_if ((in_place_init_if_t::init_tag())); BOOST_INLINE_CONSTEXPR in_place_init_if_t in_place_init_if ((in_place_init_if_t::init_tag()));
} // namespace optional_ns } // namespace optional_ns