11// Copyright Ruslan Arutyunyan, 2019-2021.
2- // Copyright Antony Polukhin, 2021-2024 .
2+ // Copyright Antony Polukhin, 2021-2025 .
33//
44// Distributed under the Boost Software License, Version 1.0. (See
55// accompanying file LICENSE_1_0.txt or copy at
1010#ifndef BOOST_ANYS_BASIC_ANY_HPP_INCLUDED
1111#define BOOST_ANYS_BASIC_ANY_HPP_INCLUDED
1212
13+ #include < boost/any/detail/config.hpp>
14+
15+ #if !defined(BOOST_USE_MODULES) || defined(BOOST_ANY_INTERFACE_UNIT)
16+
17+ // / \file boost/any/basic_any.hpp
18+ // / \brief \copybrief boost::anys::basic_any
19+
20+ #ifndef BOOST_ANY_INTERFACE_UNIT
1321#include < boost/config.hpp>
1422#ifdef BOOST_HAS_PRAGMA_ONCE
1523# pragma once
1624#endif
1725
18- // / \file boost/any/basic_any.hpp
19- // / \brief \copybrief boost::anys::basic_any
26+ # include < memory > // for std::addressof
27+ # include < type_traits >
2028
21- #include < boost/any/bad_any_cast.hpp>
22- #include < boost/any/fwd.hpp>
2329#include < boost/assert.hpp>
2430#include < boost/type_index.hpp>
2531#include < boost/throw_exception.hpp>
32+ #endif // #ifndef BOOST_ANY_INTERFACE_UNIT
2633
27- #include < memory> // for std::addressof
28- #include < type_traits>
29-
34+ #include < boost/any/bad_any_cast.hpp>
35+ #include < boost/any/fwd.hpp>
3036
3137namespace boost {
3238
3339namespace anys {
3440
41+ BOOST_ANY_BEGIN_MODULE_EXPORT
42+
3543 // / \brief A class with customizable Small Object Optimization whose
3644 // / instances can hold instances of any type that satisfies
3745 // / \forcedlink{ValueType} requirements. Use boost::any instead if not sure.
@@ -167,7 +175,7 @@ namespace anys {
167175 template <typename ValueType>
168176 static void create (basic_any& any, const ValueType& value, std::true_type)
169177 {
170- typedef typename std::decay<const ValueType>::type DecayedType ;
178+ using DecayedType = typename std::decay<const ValueType>::type;
171179
172180 any.man = &small_manager<DecayedType>;
173181 new (&any.content .small_value ) ValueType (value);
@@ -176,7 +184,7 @@ namespace anys {
176184 template <typename ValueType>
177185 static void create (basic_any& any, const ValueType& value, std::false_type)
178186 {
179- typedef typename std::decay<const ValueType>::type DecayedType ;
187+ using DecayedType = typename std::decay<const ValueType>::type;
180188
181189 any.man = &large_manager<DecayedType>;
182190 any.content .large_value = new DecayedType (value);
@@ -185,15 +193,15 @@ namespace anys {
185193 template <typename ValueType>
186194 static void create (basic_any& any, ValueType&& value, std::true_type)
187195 {
188- typedef typename std::decay<const ValueType>::type DecayedType ;
196+ using DecayedType = typename std::decay<const ValueType>::type;
189197 any.man = &small_manager<DecayedType>;
190198 new (&any.content .small_value ) DecayedType (std::forward<ValueType>(value));
191199 }
192200
193201 template <typename ValueType>
194202 static void create (basic_any& any, ValueType&& value, std::false_type)
195203 {
196- typedef typename std::decay<const ValueType>::type DecayedType ;
204+ using DecayedType = typename std::decay<const ValueType>::type;
197205 any.man = &large_manager<DecayedType>;
198206 any.content .large_value = new DecayedType (std::forward<ValueType>(value));
199207 }
@@ -283,7 +291,7 @@ namespace anys {
283291 , typename std::enable_if<!std::is_const<ValueType>::value >::type* = 0 ) // disable if value has type `const ValueType&&`
284292 : man(0 ), content()
285293 {
286- typedef typename std::decay<ValueType>::type DecayedType ;
294+ using DecayedType = typename std::decay<ValueType>::type;
287295 static_assert (
288296 !std::is_same<DecayedType, boost::any>::value,
289297 " boost::anys::basic_any shall not be constructed from boost::any"
@@ -383,7 +391,7 @@ namespace anys {
383391 template <class ValueType >
384392 basic_any & operator =(ValueType&& rhs)
385393 {
386- typedef typename std::decay<ValueType>::type DecayedType ;
394+ using DecayedType = typename std::decay<ValueType>::type;
387395 static_assert (
388396 !std::is_same<DecayedType, boost::any>::value,
389397 " boost::any shall not be assigned into boost::anys::basic_any"
@@ -475,7 +483,7 @@ namespace anys {
475483 template <typename ValueType, std::size_t OptimizeForSize, std::size_t OptimizeForAlignment>
476484 ValueType any_cast (basic_any<OptimizeForSize, OptimizeForAlignment> & operand)
477485 {
478- typedef typename std::remove_reference<ValueType>::type nonref ;
486+ using nonref = typename std::remove_reference<ValueType>::type;
479487
480488 nonref * result = boost::anys::any_cast<nonref>(std::addressof (operand));
481489 if (!result)
@@ -507,7 +515,7 @@ namespace anys {
507515 template <typename ValueType, std::size_t OptimizeForSize, std::size_t OptimizeForAlignment>
508516 inline ValueType any_cast (const basic_any<OptimizeForSize, OptimizeForAlignment> & operand)
509517 {
510- typedef typename std::remove_reference<ValueType>::type nonref ;
518+ using nonref = typename std::remove_reference<ValueType>::type;
511519 return boost::anys::any_cast<const nonref &>(const_cast <basic_any<OptimizeForSize, OptimizeForAlignment> &>(operand));
512520 }
513521
@@ -546,11 +554,19 @@ namespace anys {
546554 }
547555 // / @endcond
548556
557+ BOOST_ANY_END_MODULE_EXPORT
558+
549559} // namespace anys
550560
561+ BOOST_ANY_BEGIN_MODULE_EXPORT
562+
551563using boost::anys::any_cast;
552564using boost::anys::unsafe_any_cast;
553565
566+ BOOST_ANY_END_MODULE_EXPORT
567+
554568} // namespace boost
555569
570+ #endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_ANY_INTERFACE_UNIT)
571+
556572#endif // #ifndef BOOST_ANYS_BASIC_ANY_HPP_INCLUDED
0 commit comments