diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2023-08-14 23:34:02 +0300 |
---|---|---|
committer | robot-contrib <robot-contrib@yandex-team.com> | 2023-08-15 11:35:57 +0300 |
commit | fe1c87103984805cb9bed5066a213ac8621d0ff8 (patch) | |
tree | 163e7574a80de86e6a83d42a5e78581ebc07baf8 | |
parent | 47ace65860ecfc1847d37e029c099605143f9236 (diff) | |
download | ydb-fe1c87103984805cb9bed5066a213ac8621d0ff8.tar.gz |
Update contrib/restricted/boost/any to 1.83.0
5 files changed, 218 insertions, 70 deletions
diff --git a/contrib/restricted/boost/any/include/boost/any.hpp b/contrib/restricted/boost/any/include/boost/any.hpp index 33cc24af44..1500964c37 100644 --- a/contrib/restricted/boost/any/include/boost/any.hpp +++ b/contrib/restricted/boost/any/include/boost/any.hpp @@ -8,6 +8,9 @@ # pragma once #endif +/// \file boost/any.hpp +/// \brief \copybrief boost::any + // what: variant type boost::any // who: contributed by Kevlin Henney, // with features contributed and bugs found by @@ -17,6 +20,7 @@ #include <boost/any/bad_any_cast.hpp> #include <boost/any/fwd.hpp> +#include <boost/any/detail/placeholder.hpp> #include <boost/type_index.hpp> #include <boost/type_traits/remove_reference.hpp> #include <boost/type_traits/decay.hpp> @@ -33,15 +37,24 @@ namespace boost { + /// \brief A class whose instances can hold instances of any + /// type that satisfies \forcedlink{ValueType} requirements. class any { - public: // structors + public: + /// \post this->empty() is true. BOOST_CONSTEXPR any() BOOST_NOEXCEPT : content(0) { } + /// Makes a copy of `value`, so + /// that the initial content of the new instance is equivalent + /// in both type and value to `value`. + /// + /// \throws std::bad_alloc or any exceptions arising from the copy + /// constructor of the contained type. template<typename ValueType> any(const ValueType & value) : content(new holder< @@ -54,20 +67,39 @@ namespace boost ); } + /// Copy constructor that copies content of + /// `other` into new instance, so that any content + /// is equivalent in both type and value to the content of + /// `other`, or empty if `other` is empty. + /// + /// \throws May fail with a `std::bad_alloc` + /// exception or any exceptions arising from the copy + /// constructor of the contained type. any(const any & other) : content(other.content ? other.content->clone() : 0) { } #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - // Move constructor + /// Move constructor that moves content of + /// `other` into new instance and leaves `other` empty. + /// + /// \pre C++11 compatible compiler + /// \post other->empty() is true + /// \throws Nothing. any(any&& other) BOOST_NOEXCEPT : content(other.content) { other.content = 0; } - // Perfect forwarding of ValueType + /// Forwards `value`, so + /// that the initial content of the new instance is equivalent + /// in both type and value to `value` before the forward. + /// + /// \pre C++11 compatible compiler. + /// \throws std::bad_alloc or any exceptions arising from the move or + /// copy constructor of the contained type. template<typename ValueType> any(ValueType&& value , typename boost::disable_if<boost::is_same<any&, ValueType> >::type* = 0 // disable if value has type `any&` @@ -81,6 +113,9 @@ namespace boost } #endif + /// Releases any and all resources used in management of instance. + /// + /// \throws Nothing. ~any() BOOST_NOEXCEPT { delete content; @@ -88,6 +123,10 @@ namespace boost public: // modifiers + /// Exchange of the contents of `*this` and `rhs`. + /// + /// \returns `*this` + /// \throws Nothing. any & swap(any & rhs) BOOST_NOEXCEPT { placeholder* tmp = content; @@ -96,8 +135,31 @@ namespace boost return *this; } + /// Copies content of `rhs` into + /// current instance, discarding previous content, so that the + /// new content is equivalent in both type and value to the + /// content of `rhs`, or empty if `rhs.empty()`. + /// + /// \throws std::bad_alloc + /// or any exceptions arising from the copy constructor of the + /// contained type. Assignment satisfies the strong guarantee + /// of exception safety. + any & operator=(const any& rhs) + { + any(rhs).swap(*this); + return *this; + } #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES + /// Makes a copy of `rhs`, + /// discarding previous content, so that the new content of is + /// equivalent in both type and value to + /// `rhs`. + /// + /// \throws std::bad_alloc + /// or any exceptions arising from the copy constructor of the + /// contained type. Assignment satisfies the strong guarantee + /// of exception safety. template<typename ValueType> any & operator=(const ValueType & rhs) { @@ -108,21 +170,16 @@ namespace boost any(rhs).swap(*this); return *this; } - - any & operator=(any rhs) - { - rhs.swap(*this); - return *this; - } - #else - any & operator=(const any& rhs) - { - any(rhs).swap(*this); - return *this; - } - - // move assignment + /// Moves content of `rhs` into + /// current instance, discarding previous content, so that the + /// new content is equivalent in both type and value to the + /// content of `rhs` before move, or empty if + /// `rhs.empty()`. + /// + /// \pre C++11 compatible compiler. + /// \post `rhs->empty()` is true + /// \throws Nothing. any & operator=(any&& rhs) BOOST_NOEXCEPT { rhs.swap(*this); @@ -130,7 +187,16 @@ namespace boost return *this; } - // Perfect forwarding of ValueType + /// Forwards `rhs`, + /// discarding previous content, so that the new content of is + /// equivalent in both type and value to + /// `rhs` before forward. + /// + /// \pre C++11 compatible compiler. + /// \throws std::bad_alloc + /// or any exceptions arising from the move or copy constructor of the + /// contained type. Assignment satisfies the strong guarantee + /// of exception safety. template <class ValueType> any & operator=(ValueType&& rhs) { @@ -145,16 +211,25 @@ namespace boost public: // queries + /// \returns `true` if instance is empty, otherwise `false`. + /// \throws Nothing. bool empty() const BOOST_NOEXCEPT { return !content; } + /// \post this->empty() is true void clear() BOOST_NOEXCEPT { any().swap(*this); } + /// \returns the `typeid` of the + /// contained value if instance is non-empty, otherwise + /// `typeid(void)`. + /// + /// Useful for querying against types known either at compile time or + /// only at runtime. const boost::typeindex::type_info& type() const BOOST_NOEXCEPT { return content ? content->type() : boost::typeindex::type_id<void>().type_info(); @@ -165,21 +240,11 @@ namespace boost #else public: // types (public so any_cast can be non-friend) #endif - - class BOOST_SYMBOL_VISIBLE placeholder + /// @cond + class BOOST_SYMBOL_VISIBLE placeholder: public boost::anys::detail::placeholder { - public: // structors - - virtual ~placeholder() - { - } - - public: // queries - - virtual const boost::typeindex::type_info& type() const BOOST_NOEXCEPT = 0; - + public: virtual placeholder * clone() const = 0; - }; template<typename ValueType> @@ -225,13 +290,11 @@ namespace boost #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS private: // representation - - template<typename ValueType> - friend ValueType * any_cast(any *) BOOST_NOEXCEPT; - template<typename ValueType> friend ValueType * unsafe_any_cast(any *) BOOST_NOEXCEPT; + friend class boost::anys::unique_any; + #else public: // representation (public so any_cast can be non-friend) @@ -239,37 +302,65 @@ namespace boost #endif placeholder * content; - + /// @endcond }; + /// Exchange of the contents of `lhs` and `rhs`. + /// \throws Nothing. inline void swap(any & lhs, any & rhs) BOOST_NOEXCEPT { lhs.swap(rhs); } + /// @cond + + // Note: The "unsafe" versions of any_cast are not part of the + // public interface and may be removed at any time. They are + // required where we know what type is stored in the any and can't + // use typeid() comparison, e.g., when our types may travel across + // different shared libraries. + template<typename ValueType> + inline ValueType * unsafe_any_cast(any * operand) BOOST_NOEXCEPT + { + return boost::addressof( + static_cast<any::holder<ValueType> *>(operand->content)->held + ); + } + + template<typename ValueType> + inline const ValueType * unsafe_any_cast(const any * operand) BOOST_NOEXCEPT + { + return boost::unsafe_any_cast<ValueType>(const_cast<any *>(operand)); + } + /// @endcond + + /// \returns Pointer to a ValueType stored in `operand`, nullptr if + /// `operand` does not contain specified `ValueType`. template<typename ValueType> ValueType * any_cast(any * operand) BOOST_NOEXCEPT { return operand && operand->type() == boost::typeindex::type_id<ValueType>() - ? boost::addressof( - static_cast<any::holder<BOOST_DEDUCED_TYPENAME remove_cv<ValueType>::type> *>(operand->content)->held - ) + ? boost::unsafe_any_cast<BOOST_DEDUCED_TYPENAME boost::remove_cv<ValueType>::type>(operand) : 0; } + /// \returns Const pointer to a ValueType stored in `operand`, nullptr if + /// `operand` does not contain specified `ValueType`. template<typename ValueType> inline const ValueType * any_cast(const any * operand) BOOST_NOEXCEPT { - return any_cast<ValueType>(const_cast<any *>(operand)); + return boost::any_cast<ValueType>(const_cast<any *>(operand)); } + /// \returns ValueType stored in `operand` + /// \throws boost::bad_any_cast if `operand` does not contain + /// specified ValueType. template<typename ValueType> ValueType any_cast(any & operand) { typedef BOOST_DEDUCED_TYPENAME remove_reference<ValueType>::type nonref; - - nonref * result = any_cast<nonref>(boost::addressof(operand)); + nonref * result = boost::any_cast<nonref>(boost::addressof(operand)); if(!result) boost::throw_exception(bad_any_cast()); @@ -293,14 +384,20 @@ namespace boost #endif } + /// \returns `ValueType` stored in `operand` + /// \throws boost::bad_any_cast if `operand` does not contain + /// specified `ValueType`. template<typename ValueType> inline ValueType any_cast(const any & operand) { typedef BOOST_DEDUCED_TYPENAME remove_reference<ValueType>::type nonref; - return any_cast<const nonref &>(const_cast<any &>(operand)); + return boost::any_cast<const nonref &>(const_cast<any &>(operand)); } #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + /// \returns `ValueType` stored in `operand`, leaving the `operand` empty. + /// \throws boost::bad_any_cast if `operand` does not contain + /// specified `ValueType`. template<typename ValueType> inline ValueType any_cast(any&& operand) { @@ -309,29 +406,9 @@ namespace boost || boost::is_const< typename boost::remove_reference<ValueType>::type >::value, "boost::any_cast shall not be used for getting nonconst references to temporary objects" ); - return any_cast<ValueType>(operand); + return boost::any_cast<ValueType>(operand); } #endif - - - // Note: The "unsafe" versions of any_cast are not part of the - // public interface and may be removed at any time. They are - // required where we know what type is stored in the any and can't - // use typeid() comparison, e.g., when our types may travel across - // different shared libraries. - template<typename ValueType> - inline ValueType * unsafe_any_cast(any * operand) BOOST_NOEXCEPT - { - return boost::addressof( - static_cast<any::holder<ValueType> *>(operand->content)->held - ); - } - - template<typename ValueType> - inline const ValueType * unsafe_any_cast(const any * operand) BOOST_NOEXCEPT - { - return unsafe_any_cast<ValueType>(const_cast<any *>(operand)); - } } // Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved. diff --git a/contrib/restricted/boost/any/include/boost/any/bad_any_cast.hpp b/contrib/restricted/boost/any/include/boost/any/bad_any_cast.hpp index 3c5335ccc2..e715938e71 100644 --- a/contrib/restricted/boost/any/include/boost/any/bad_any_cast.hpp +++ b/contrib/restricted/boost/any/include/boost/any/bad_any_cast.hpp @@ -22,6 +22,8 @@ namespace boost { +/// The exception thrown in the event of a failed boost::any_cast of +/// an boost::any, boost::anys::basic_any or boost::anys::unique_any value. class BOOST_SYMBOL_VISIBLE bad_any_cast : #ifndef BOOST_NO_RTTI public std::bad_cast diff --git a/contrib/restricted/boost/any/include/boost/any/detail/placeholder.hpp b/contrib/restricted/boost/any/include/boost/any/detail/placeholder.hpp new file mode 100644 index 0000000000..df5db65495 --- /dev/null +++ b/contrib/restricted/boost/any/include/boost/any/detail/placeholder.hpp @@ -0,0 +1,33 @@ +// Copyright Antony Polukhin, 2021-2023. +// +// 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) + +#ifndef BOOST_ANY_ANYS_DETAIL_PLACEHOLDER_HPP +#define BOOST_ANY_ANYS_DETAIL_PLACEHOLDER_HPP + +#include <boost/config.hpp> +#ifdef BOOST_HAS_PRAGMA_ONCE +# pragma once +#endif + +#include <boost/type_index.hpp> + +/// @cond +namespace boost { +namespace anys { +namespace detail { + +class BOOST_SYMBOL_VISIBLE placeholder { +public: + virtual ~placeholder() {} + virtual const boost::typeindex::type_info& type() const BOOST_NOEXCEPT = 0; +}; + +} // namespace detail +} // namespace anys +} // namespace boost +/// @endcond + +#endif // #ifndef BOOST_ANY_ANYS_DETAIL_PLACEHOLDER_HPP diff --git a/contrib/restricted/boost/any/include/boost/any/fwd.hpp b/contrib/restricted/boost/any/include/boost/any/fwd.hpp index 551eb90403..21c5bc9877 100644 --- a/contrib/restricted/boost/any/include/boost/any/fwd.hpp +++ b/contrib/restricted/boost/any/include/boost/any/fwd.hpp @@ -13,28 +13,64 @@ # pragma once #endif - #include <boost/type_traits/alignment_of.hpp> +/// \file boost/any/fwd.hpp +/// \brief Forward declarations of Boost.Any library types. + +#include <boost/config/pragma_message.hpp> +#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || \ + defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) || \ + defined(BOOST_NO_CXX11_CONSTEXPR) || \ + defined(BOOST_NO_CXX11_NULLPTR) || \ + defined(BOOST_NO_CXX11_NOEXCEPT) || \ + defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || \ + defined(BOOST_NO_CXX11_FINAL) || \ + defined(BOOST_NO_CXX11_ALIGNOF) || \ + defined(BOOST_NO_CXX11_STATIC_ASSERT) || \ + defined(BOOST_NO_CXX11_SMART_PTR) || \ + defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) || \ + defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) + +BOOST_PRAGMA_MESSAGE("C++03 support is deprecated in Boost.Any 1.82 and will be removed in Boost.Any 1.84.") + +#endif + +#include <boost/type_traits/alignment_of.hpp> + +/// @cond namespace boost { class any; namespace anys { +class unique_any; + template<std::size_t OptimizeForSize = sizeof(void*), std::size_t OptimizeForAlignment = boost::alignment_of<void*>::value> class basic_any; namespace detail { - template <class T> - struct is_basic_any: public false_type {}; + template <class T> + struct is_basic_any: public boost::false_type {}; template<std::size_t OptimizeForSize, std::size_t OptimizeForAlignment> - struct is_basic_any<boost::anys::basic_any<OptimizeForSize, OptimizeForAlignment> > : public true_type {}; + struct is_basic_any<boost::anys::basic_any<OptimizeForSize, OptimizeForAlignment> > : public boost::true_type {}; + + template <class T> + struct is_some_any: public is_basic_any<T> {}; + + template <> + struct is_some_any<boost::any>: public boost::true_type {}; + + template <> + struct is_some_any<boost::anys::unique_any>: public boost::true_type {}; + } // namespace detail } // namespace anys } // namespace boost +/// @endcond #endif // #ifndef BOOST_ANY_ANYS_FWD_HPP diff --git a/contrib/restricted/boost/any/ya.make b/contrib/restricted/boost/any/ya.make index 11120291f6..378225550d 100644 --- a/contrib/restricted/boost/any/ya.make +++ b/contrib/restricted/boost/any/ya.make @@ -6,9 +6,9 @@ LICENSE(BSL-1.0) LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(1.82.0) +VERSION(1.83.0) -ORIGINAL_SOURCE(https://github.com/boostorg/any/archive/boost-1.82.0.tar.gz) +ORIGINAL_SOURCE(https://github.com/boostorg/any/archive/boost-1.83.0.tar.gz) PEERDIR( contrib/restricted/boost/config |