2626// ! Defines boost::container::from_range_t and the boost::container::from_range
2727// ! tag, used to disambiguate the range-based members of the containers.
2828// !
29- // ! Following the same technique as boost::container::piecewise_construct_t and
30- // ! boost::container::allocator_arg_t, from_range_t is a reference to the
31- // ! standard ::std::from_range_t (only forward declared in <std_fwd.hpp>), so
32- // ! the tag is the very same type as the standard one and interoperates with
33- // ! ::std::from_range, yet the heavyweight <ranges> header is not required.
29+ // ! When the standard library provides ::std::from_range_t (feature-test macro
30+ // ! __cpp_lib_containers_ranges), from_range_t is a reference to it -following
31+ // ! the same technique as boost::container::piecewise_construct_t and
32+ // ! boost::container::allocator_arg_t- so the tag is the very same type as the
33+ // ! standard one and interoperates with ::std::from_range, yet the heavyweight
34+ // ! <ranges> header is not required. Otherwise, there is no standard type to
35+ // ! refer to and from_range_t is defined as a standalone type.
3436
3537namespace boost {
3638namespace container {
3739
3840#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
3941
42+ #if defined(__cpp_lib_containers_ranges)
43+
4044 template <int Dummy = 0 >
4145 struct std_from_range_holder
4246 {
@@ -48,18 +52,31 @@ namespace container {
4852
4953typedef const ::std::from_range_t & from_range_t ;
5054
51- #else
55+ // ! A instance of type from_range_t
56+ static from_range_t from_range = *std_from_range_holder<>::dummy;
57+
58+ #else // !defined(__cpp_lib_containers_ranges)
59+
60+ // The standard library does not provide ::std::from_range_t, so there is nothing
61+ // to interoperate with: from_range_t is a standalone type.
62+ struct from_range_t {};
63+
64+ // ! A instance of type from_range_t
65+ static const from_range_t from_range = from_range_t ();
66+
67+ #endif // defined(__cpp_lib_containers_ranges)
68+
69+ #else // BOOST_CONTAINER_DOXYGEN_INVOKED
5270
5371// ! The from_range_t struct is an empty structure type used as a unique type to
5472// ! disambiguate the constructors and member functions that build or replace the
5573// ! contents of a container from a container-compatible range.
5674typedef unspecified from_range_t ;
5775
58- #endif // #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
76+ // ! A instance of type from_range_t
77+ static from_range_t from_range;
5978
60- // ! A instance of type
61- // ! from_range_t
62- static from_range_t from_range = BOOST_CONTAINER_DOC1ST (unspecified, *std_from_range_holder<>::dummy);
79+ #endif // #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
6380
6481// /@cond
6582
0 commit comments