diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2022-08-11 16:44:37 +0300 |
---|---|---|
committer | robot-contrib <robot-contrib@yandex-team.com> | 2022-08-11 16:44:37 +0300 |
commit | 12b29c0456df718b7137cf270cbecd5b98b6fc24 (patch) | |
tree | 39c9b15805298c1df3b0123a307a9287870a0fa2 | |
parent | 8391f5f5e2e77701f2cc1ef98deb1254dd0ecab2 (diff) | |
download | ydb-12b29c0456df718b7137cf270cbecd5b98b6fc24.tar.gz |
Update contrib/restricted/boost/optional to 1.80.0
5 files changed, 172 insertions, 50 deletions
diff --git a/contrib/restricted/boost/optional/include/boost/optional/detail/optional_aligned_storage.hpp b/contrib/restricted/boost/optional/include/boost/optional/detail/optional_aligned_storage.hpp index 2937349f52..b290921d35 100644 --- a/contrib/restricted/boost/optional/include/boost/optional/detail/optional_aligned_storage.hpp +++ b/contrib/restricted/boost/optional/include/boost/optional/detail/optional_aligned_storage.hpp @@ -28,7 +28,7 @@ class aligned_storage // BOOST_MAY_ALIAS works around GCC warnings about breaking strict aliasing rules when casting storage address to T* union BOOST_MAY_ALIAS dummy_u { - char data[ sizeof(T) ]; + unsigned char data[ sizeof(T) ]; BOOST_DEDUCED_TYPENAME type_with_alignment< ::boost::alignment_of<T>::value >::type aligner_; } dummy_ ; diff --git a/contrib/restricted/boost/optional/include/boost/optional/detail/optional_hash.hpp b/contrib/restricted/boost/optional/include/boost/optional/detail/optional_hash.hpp new file mode 100644 index 0000000000..234ee7b6ea --- /dev/null +++ b/contrib/restricted/boost/optional/include/boost/optional/detail/optional_hash.hpp @@ -0,0 +1,49 @@ +// Copyright (C) 2022 Andrzej Krzemienski. +// +// Use, modification, and distribution is subject to 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) +// +// See http://www.boost.org/libs/optional for documentation. +// +// You are welcome to contact the author at: +// akrzemi1@gmail.com + +#ifndef BOOST_OPTIONAL_DETAIL_OPTIONAL_HASH_AJK_20MAY2022_HPP +#define BOOST_OPTIONAL_DETAIL_OPTIONAL_HASH_AJK_20MAY2022_HPP + +#include <boost/optional/optional_fwd.hpp> +#include <boost/config.hpp> + +#if !defined(BOOST_OPTIONAL_CONFIG_DO_NOT_SPECIALIZE_STD_HASH) && !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL) + +#include <functional> + +namespace std +{ + template <typename T> + struct hash<boost::optional<T> > + { + typedef std::size_t result_type; + typedef boost::optional<T> argument_type; + + BOOST_CONSTEXPR result_type operator()(const argument_type& arg) const { + return arg ? std::hash<T>()(*arg) : result_type(); + } + }; + + template <typename T> + struct hash<boost::optional<T&> > + { + typedef std::size_t result_type; + typedef boost::optional<T&> argument_type; + + BOOST_CONSTEXPR result_type operator()(const argument_type& arg) const { + return arg ? std::hash<T>()(*arg) : result_type(); + } + }; +} + +#endif // !defined(BOOST_OPTIONAL_CONFIG_DO_NOT_SPECIALIZE_STD_HASH) && !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL) + +#endif // header guard diff --git a/contrib/restricted/boost/optional/include/boost/optional/detail/optional_trivially_copyable_base.hpp b/contrib/restricted/boost/optional/include/boost/optional/detail/optional_trivially_copyable_base.hpp index 2cabf9a7c6..5a5b80b6f0 100644 --- a/contrib/restricted/boost/optional/include/boost/optional/detail/optional_trivially_copyable_base.hpp +++ b/contrib/restricted/boost/optional/include/boost/optional/detail/optional_trivially_copyable_base.hpp @@ -1,3 +1,14 @@ +// Copyright (C) 2017 Andrzej Krzemienski. +// +// Use, modification, and distribution is subject to 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) +// +// See http://www.boost.org/libs/optional for documentation. +// +// You are welcome to contact the author at: +// akrzemi1@gmail.com + // trivilally-copyable version of the storage template<class T> @@ -69,7 +80,7 @@ class tc_optional_base : public optional_tag // ~tc_optional_base() = default; // Assigns from another optional<T> (deep-copies the rhs value) - void assign ( tc_optional_base const& rhs ) + void assign ( tc_optional_base const& rhs ) { *this = rhs; } @@ -84,7 +95,7 @@ class tc_optional_base : public optional_tag #else m_storage = static_cast<value_type>(rhs.get()); #endif - + m_initialized = rhs.is_initialized(); } @@ -99,7 +110,7 @@ class tc_optional_base : public optional_tag m_initialized = rhs.is_initialized(); } #endif - + void assign ( argument_type val ) { construct(val); @@ -166,7 +177,7 @@ class tc_optional_base : public optional_tag { construct(in_place_init, boost::forward<Args>(args)...); } - + template<class... Args> explicit tc_optional_base ( in_place_init_t, Args&&... args ) : @@ -174,7 +185,7 @@ class tc_optional_base : public optional_tag { construct(in_place_init, boost::forward<Args>(args)...); } - + template<class... Args> explicit tc_optional_base ( in_place_init_if_t, bool cond, Args&&... args ) : @@ -190,24 +201,24 @@ class tc_optional_base : public optional_tag m_storage = value_type( boost::forward<Arg>(arg) ); m_initialized = true ; } - + void construct ( in_place_init_t ) { m_storage = value_type(); m_initialized = true ; } - + template<class Arg> void emplace_assign ( Arg&& arg ) { construct(in_place_init, boost::forward<Arg>(arg)) ; } - + void emplace_assign () { construct(in_place_init) ; } - + template<class Arg> explicit tc_optional_base ( in_place_init_t, Arg&& arg ) : @@ -215,11 +226,11 @@ class tc_optional_base : public optional_tag { construct(in_place_init, boost::forward<Arg>(arg)); } - + explicit tc_optional_base ( in_place_init_t ) : m_initialized(false), m_storage() {} - + template<class Arg> explicit tc_optional_base ( in_place_init_if_t, bool cond, Arg&& arg ) : @@ -228,7 +239,7 @@ class tc_optional_base : public optional_tag if ( cond ) construct(in_place_init, boost::forward<Arg>(arg)); } - + explicit tc_optional_base ( in_place_init_if_t, bool cond ) : m_initialized(false) @@ -238,21 +249,21 @@ class tc_optional_base : public optional_tag } #else - + template<class Arg> void construct ( in_place_init_t, const Arg& arg ) { m_storage = value_type( arg ); m_initialized = true ; } - + template<class Arg> void construct ( in_place_init_t, Arg& arg ) { m_storage = value_type( arg ); m_initialized = true ; } - + void construct ( in_place_init_t ) { m_storage = value_type(); @@ -264,18 +275,18 @@ class tc_optional_base : public optional_tag { construct(in_place_init, arg); } - + template<class Arg> void emplace_assign ( Arg& arg ) { construct(in_place_init, arg); } - + void emplace_assign () { construct(in_place_init); } - + template<class Arg> explicit tc_optional_base ( in_place_init_t, const Arg& arg ) : m_initialized(false) @@ -289,13 +300,13 @@ class tc_optional_base : public optional_tag { construct(in_place_init, arg); } - + explicit tc_optional_base ( in_place_init_t ) : m_initialized(false) { construct(in_place_init); } - + template<class Arg> explicit tc_optional_base ( in_place_init_if_t, bool cond, const Arg& arg ) : m_initialized(false) @@ -303,15 +314,15 @@ class tc_optional_base : public optional_tag if ( cond ) construct(in_place_init, arg); } - + template<class Arg> explicit tc_optional_base ( in_place_init_if_t, bool cond, Arg& arg ) : m_initialized(false) { if ( cond ) construct(in_place_init, arg); - } - + } + explicit tc_optional_base ( in_place_init_if_t, bool cond ) : m_initialized(false) { diff --git a/contrib/restricted/boost/optional/include/boost/optional/optional.hpp b/contrib/restricted/boost/optional/include/boost/optional/optional.hpp index aadc975a7a..4134a7e558 100644 --- a/contrib/restricted/boost/optional/include/boost/optional/optional.hpp +++ b/contrib/restricted/boost/optional/include/boost/optional/optional.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2003, 2008 Fernando Luis Cacciola Carballal. -// Copyright (C) 2014 - 2018 Andrzej Krzemienski. +// Copyright (C) 2014 - 2021 Andrzej Krzemienski. // // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -18,7 +18,9 @@ #define BOOST_OPTIONAL_OPTIONAL_FLC_19NOV2002_HPP #include <new> +#ifndef BOOST_NO_IOSTREAM #include <iosfwd> +#endif // BOOST_NO_IOSTREAM #ifdef BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS # include <type_traits> @@ -35,14 +37,18 @@ #include <boost/type.hpp> #include <boost/type_traits/alignment_of.hpp> #include <boost/type_traits/conditional.hpp> +#include <boost/type_traits/conjunction.hpp> +#include <boost/type_traits/disjunction.hpp> #include <boost/type_traits/has_nothrow_constructor.hpp> #include <boost/type_traits/type_with_alignment.hpp> #include <boost/type_traits/remove_const.hpp> #include <boost/type_traits/remove_reference.hpp> #include <boost/type_traits/decay.hpp> +#include <boost/type_traits/is_assignable.hpp> #include <boost/type_traits/is_base_of.hpp> #include <boost/type_traits/is_const.hpp> #include <boost/type_traits/is_constructible.hpp> +#include <boost/type_traits/is_convertible.hpp> #include <boost/type_traits/is_lvalue_reference.hpp> #include <boost/type_traits/is_nothrow_move_assignable.hpp> #include <boost/type_traits/is_nothrow_move_constructible.hpp> @@ -59,6 +65,7 @@ #include <boost/optional/detail/optional_config.hpp> #include <boost/optional/detail/optional_factory_support.hpp> #include <boost/optional/detail/optional_aligned_storage.hpp> +#include <boost/optional/detail/optional_hash.hpp> namespace boost { namespace optional_detail { @@ -123,6 +130,7 @@ class optional_base : public optional_tag protected : typedef T value_type ; + typedef typename boost::remove_const<T>::type unqualified_value_type; protected: typedef T & reference_type ; @@ -399,14 +407,14 @@ class optional_base : public optional_tag void construct ( argument_type val ) { - ::new (m_storage.address()) value_type(val) ; + ::new (m_storage.address()) unqualified_value_type(val) ; m_initialized = true ; } #ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES void construct ( rval_reference_type val ) { - ::new (m_storage.address()) value_type( boost::move(val) ) ; + ::new (m_storage.address()) unqualified_value_type( boost::move(val) ) ; m_initialized = true ; } #endif @@ -418,7 +426,7 @@ class optional_base : public optional_tag template<class... Args> void construct ( in_place_init_t, Args&&... args ) { - ::new (m_storage.address()) value_type( boost::forward<Args>(args)... ) ; + ::new (m_storage.address()) unqualified_value_type( boost::forward<Args>(args)... ) ; m_initialized = true ; } @@ -449,13 +457,13 @@ class optional_base : public optional_tag template<class Arg> void construct ( in_place_init_t, Arg&& arg ) { - ::new (m_storage.address()) value_type( boost::forward<Arg>(arg) ); + ::new (m_storage.address()) unqualified_value_type( boost::forward<Arg>(arg) ); m_initialized = true ; } void construct ( in_place_init_t ) { - ::new (m_storage.address()) value_type(); + ::new (m_storage.address()) unqualified_value_type(); m_initialized = true ; } @@ -509,20 +517,20 @@ class optional_base : public optional_tag template<class Arg> void construct ( in_place_init_t, const Arg& arg ) { - ::new (m_storage.address()) value_type( arg ); + ::new (m_storage.address()) unqualified_value_type( arg ); m_initialized = true ; } template<class Arg> void construct ( in_place_init_t, Arg& arg ) { - ::new (m_storage.address()) value_type( arg ); + ::new (m_storage.address()) unqualified_value_type( arg ); m_initialized = true ; } void construct ( in_place_init_t ) { - ::new (m_storage.address()) value_type(); + ::new (m_storage.address()) unqualified_value_type(); m_initialized = true ; } @@ -667,7 +675,7 @@ class optional_base : public optional_tag template<class Expr> void construct ( Expr&& expr, void const* ) { - new (m_storage.address()) value_type(boost::forward<Expr>(expr)) ; + new (m_storage.address()) unqualified_value_type(boost::forward<Expr>(expr)) ; m_initialized = true ; } @@ -688,7 +696,7 @@ class optional_base : public optional_tag template<class Expr> void construct ( Expr const& expr, void const* ) { - new (m_storage.address()) value_type(expr) ; + new (m_storage.address()) unqualified_value_type(expr) ; m_initialized = true ; } @@ -726,7 +734,7 @@ class optional_base : public optional_tag { // An exception can be thrown here. // It it happens, THIS will be left uninitialized. - new (m_storage.address()) value_type(boost::move(expr.get())) ; + new (m_storage.address()) unqualified_value_type(boost::move(expr.get())) ; m_initialized = true ; } } @@ -739,7 +747,7 @@ class optional_base : public optional_tag { // An exception can be thrown here. // It it happens, THIS will be left uninitialized. - new (m_storage.address()) value_type(expr.get()) ; + new (m_storage.address()) unqualified_value_type(expr.get()) ; m_initialized = true ; } } @@ -779,7 +787,7 @@ class optional_base : public optional_tag // definition of metafunction is_optional_val_init_candidate template <typename U> -struct is_optional_related +struct is_optional_or_tag : boost::conditional< boost::is_base_of<optional_detail::optional_tag, BOOST_DEDUCED_TYPENAME boost::decay<U>::type>::value || boost::is_same<BOOST_DEDUCED_TYPENAME boost::decay<U>::type, none_t>::value || boost::is_same<BOOST_DEDUCED_TYPENAME boost::decay<U>::type, in_place_init_t>::value @@ -787,14 +795,22 @@ struct is_optional_related boost::true_type, boost::false_type>::type {}; +template <typename T, typename U> +struct has_dedicated_constructor + : boost::disjunction<is_optional_or_tag<U>, boost::is_same<T, BOOST_DEDUCED_TYPENAME boost::decay<U>::type> > +{}; + +template <typename U> +struct is_in_place_factory + : boost::disjunction< boost::is_base_of<boost::in_place_factory_base, BOOST_DEDUCED_TYPENAME boost::decay<U>::type>, + boost::is_base_of<boost::typed_in_place_factory_base, BOOST_DEDUCED_TYPENAME boost::decay<U>::type> > +{}; + #if !defined(BOOST_OPTIONAL_DETAIL_NO_IS_CONSTRUCTIBLE_TRAIT) template <typename T, typename U> -struct is_convertible_to_T_or_factory - : boost::conditional< boost::is_base_of<boost::in_place_factory_base, BOOST_DEDUCED_TYPENAME boost::decay<U>::type>::value - || boost::is_base_of<boost::typed_in_place_factory_base, BOOST_DEDUCED_TYPENAME boost::decay<U>::type>::value - || (boost::is_constructible<T, U&&>::value && !boost::is_same<T, BOOST_DEDUCED_TYPENAME boost::decay<U>::type>::value) - , boost::true_type, boost::false_type>::type +struct is_factory_or_constructible_to_T + : boost::disjunction< is_in_place_factory<U>, boost::is_constructible<T, U&&> > {}; template <typename T, typename U> @@ -804,7 +820,7 @@ struct is_optional_constructible : boost::is_constructible<T, U> #else template <typename, typename> -struct is_convertible_to_T_or_factory : boost::true_type +struct is_factory_or_constructible_to_T : boost::true_type {}; template <typename T, typename U> @@ -813,15 +829,58 @@ struct is_optional_constructible : boost::true_type #endif // is_convertible condition -template <typename T, typename U, bool = is_optional_related<U>::value> +#if !defined(BOOST_NO_CXX11_DECLTYPE) && !BOOST_WORKAROUND(BOOST_MSVC, < 1800) +// for is_assignable + +#if (!defined BOOST_NO_CXX11_RVALUE_REFERENCES) +// On some initial rvalue reference implementations GCC does it in a strange way, +// preferring perfect-forwarding constructor to implicit copy constructor. + +template <typename T, typename U> +struct is_opt_assignable + : boost::conjunction<boost::is_convertible<U&&, T>, boost::is_assignable<T&, U&&> > +{}; + +#else + +template <typename T, typename U> +struct is_opt_assignable + : boost::conjunction<boost::is_convertible<U, T>, boost::is_assignable<T&, U> > +{}; + +#endif + +#else + +template <typename T, typename U> +struct is_opt_assignable : boost::is_convertible<U, T> +{}; + +#endif + +template <typename T, typename U> +struct is_factory_or_opt_assignable_to_T + : boost::disjunction< is_in_place_factory<U>, is_opt_assignable<T, U> > +{}; + +template <typename T, typename U, bool = has_dedicated_constructor<T, U>::value> struct is_optional_val_init_candidate : boost::false_type {}; template <typename T, typename U> struct is_optional_val_init_candidate<T, U, false> - : boost::conditional< is_convertible_to_T_or_factory<T, U>::value - , boost::true_type, boost::false_type>::type + : is_factory_or_constructible_to_T<T, U> +{}; + +template <typename T, typename U, bool = has_dedicated_constructor<T, U>::value> +struct is_optional_val_assign_candidate + : boost::false_type +{}; + +template <typename T, typename U> +struct is_optional_val_assign_candidate<T, U, false> + : is_factory_or_opt_assignable_to_T<T, U> {}; } // namespace optional_detail @@ -994,7 +1053,7 @@ class optional #ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES template<class Expr> - BOOST_DEDUCED_TYPENAME boost::enable_if<optional_detail::is_optional_val_init_candidate<T, Expr>, optional&>::type + BOOST_DEDUCED_TYPENAME boost::enable_if<optional_detail::is_optional_val_assign_candidate<T, Expr>, optional&>::type operator= ( Expr&& expr ) { this->assign_expr(boost::forward<Expr>(expr),boost::addressof(expr)); @@ -1586,6 +1645,7 @@ get_pointer ( optional<T>& opt ) } // namespace boost +#ifndef BOOST_NO_IOSTREAM namespace boost { // The following declaration prevents a bug where operator safe-bool is used upon streaming optional object if you forget the IO header. @@ -1598,6 +1658,7 @@ operator<<(std::basic_ostream<CharType, CharTrait>& os, optional_detail::optiona } } // namespace boost +#endif // BOOST_NO_IOSTREAM #include <boost/optional/detail/optional_relops.hpp> #include <boost/optional/detail/optional_swap.hpp> diff --git a/contrib/restricted/boost/optional/include/boost/optional/optional_io.hpp b/contrib/restricted/boost/optional/include/boost/optional/optional_io.hpp index ce81b68f8e..3db6ddae76 100644 --- a/contrib/restricted/boost/optional/include/boost/optional/optional_io.hpp +++ b/contrib/restricted/boost/optional/include/boost/optional/optional_io.hpp @@ -12,6 +12,7 @@ #ifndef BOOST_OPTIONAL_OPTIONAL_IO_FLC_19NOV2002_HPP #define BOOST_OPTIONAL_OPTIONAL_IO_FLC_19NOV2002_HPP +#ifndef BOOST_NO_IOSTREAM #include <istream> #include <ostream> @@ -31,7 +32,7 @@ operator<<(std::basic_ostream<CharType, CharTrait>& out, none_t) { out << "--"; } - + return out; } @@ -90,5 +91,5 @@ operator>>(std::basic_istream<CharType, CharTrait>& in, optional<T>& v) } // namespace boost +#endif // BOOST_NO_IOSTREAM #endif - |