diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2022-08-11 16:02:03 +0300 |
---|---|---|
committer | robot-contrib <robot-contrib@yandex-team.com> | 2022-08-11 16:02:03 +0300 |
commit | fe22e5c95f37c7ee46472d920d1dbf95f412b9e6 (patch) | |
tree | 34225213b8e50e9c242f08723fc96ec0d026deaa /contrib | |
parent | 9de0b0f56f79abfaf40b017ffebb5017476415a6 (diff) | |
download | ydb-fe22e5c95f37c7ee46472d920d1dbf95f412b9e6.tar.gz |
Update contrib/restricted/boost/core to 1.80.0
Diffstat (limited to 'contrib')
6 files changed, 158 insertions, 130 deletions
diff --git a/contrib/restricted/boost/core/include/boost/core/alloc_construct.hpp b/contrib/restricted/boost/core/include/boost/core/alloc_construct.hpp index e390730a08..075d3cb362 100644 --- a/contrib/restricted/boost/core/include/boost/core/alloc_construct.hpp +++ b/contrib/restricted/boost/core/include/boost/core/alloc_construct.hpp @@ -8,6 +8,9 @@ Distributed under the Boost Software License, Version 1.0. #ifndef BOOST_CORE_ALLOC_CONSTRUCT_HPP #define BOOST_CORE_ALLOC_CONSTRUCT_HPP +/* +This functionality is now in <boost/core/allocator_access.hpp>. +*/ #include <boost/core/noinit_adaptor.hpp> namespace boost { @@ -23,58 +26,11 @@ template<class A, class T> inline void alloc_destroy_n(A& a, T* p, std::size_t n) { - while (n > 0) { - boost::allocator_destroy(a, p + --n); - } -} - -template<class A, class T> -inline void -alloc_destroy(noinit_adaptor<A>&, T* p) -{ - p->~T(); + boost::allocator_destroy_n(a, p, n); } template<class A, class T> inline void -alloc_destroy_n(noinit_adaptor<A>&, T* p, std::size_t n) -{ - while (n > 0) { - p[--n].~T(); - } -} - -namespace detail { - -template<class A, class T> -class alloc_destroyer { -public: - alloc_destroyer(A& a, T* p) BOOST_NOEXCEPT - : a_(a), - p_(p), - n_(0) { } - - ~alloc_destroyer() { - boost::alloc_destroy_n(a_, p_, n_); - } - - std::size_t& size() BOOST_NOEXCEPT { - return n_; - } - -private: - alloc_destroyer(const alloc_destroyer&); - alloc_destroyer& operator=(const alloc_destroyer&); - - A& a_; - T* p_; - std::size_t n_; -}; - -} /* detail */ - -template<class A, class T> -inline void alloc_construct(A& a, T* p) { boost::allocator_construct(a, p); @@ -117,51 +73,21 @@ template<class A, class T> inline void alloc_construct_n(A& a, T* p, std::size_t n) { - detail::alloc_destroyer<A, T> hold(a, p); - for (std::size_t& i = hold.size(); i < n; ++i) { - boost::allocator_construct(a, p + i); - } - hold.size() = 0; + boost::allocator_construct_n(a, p, n); } template<class A, class T> inline void alloc_construct_n(A& a, T* p, std::size_t n, const T* l, std::size_t m) { - detail::alloc_destroyer<A, T> hold(a, p); - for (std::size_t& i = hold.size(); i < n; ++i) { - boost::allocator_construct(a, p + i, l[i % m]); - } - hold.size() = 0; + boost::allocator_construct_n(a, p, n, l, m); } template<class A, class T, class I> inline void alloc_construct_n(A& a, T* p, std::size_t n, I b) { - detail::alloc_destroyer<A, T> hold(a, p); - for (std::size_t& i = hold.size(); i < n; void(++i), void(++b)) { - boost::allocator_construct(a, p + i, *b); - } - hold.size() = 0; -} - -template<class A, class T> -inline void -alloc_construct(noinit_adaptor<A>&, T* p) -{ - ::new(static_cast<void*>(p)) T; -} - -template<class A, class T> -inline void -alloc_construct_n(noinit_adaptor<A>& a, T* p, std::size_t n) -{ - detail::alloc_destroyer<noinit_adaptor<A>, T> hold(a, p); - for (std::size_t& i = hold.size(); i < n; ++i) { - ::new(static_cast<void*>(p + i)) T; - } - hold.size() = 0; + boost::allocator_construct_n(a, p, n, b); } } /* boost */ diff --git a/contrib/restricted/boost/core/include/boost/core/allocator_access.hpp b/contrib/restricted/boost/core/include/boost/core/allocator_access.hpp index 247ad756e9..567b448bec 100644 --- a/contrib/restricted/boost/core/include/boost/core/allocator_access.hpp +++ b/contrib/restricted/boost/core/include/boost/core/allocator_access.hpp @@ -1,5 +1,5 @@ /* -Copyright 2020-2021 Glen Joseph Fernandes +Copyright 2020-2022 Glen Joseph Fernandes (glenjofe@gmail.com) Distributed under the Boost Software License, Version 1.0. @@ -427,9 +427,55 @@ allocator_allocate(A& a, typename allocator_size_type<A>::type n, } #endif +namespace detail { + +#if defined(BOOST_NO_CXX11_ALLOCATOR) +template<class A, class = void> +struct alloc_has_construct { + BOOST_STATIC_CONSTEXPR bool value = false; +}; + +template<class A> +struct alloc_has_construct<A, + typename alloc_void<typename A::_default_construct_destroy>::type> { + BOOST_STATIC_CONSTEXPR bool value = true; +}; +#else +template<class A, class T, class... Args> +class alloc_has_construct { + template<class O> + static auto check(int) + -> alloc_no<decltype(std::declval<O&>().construct(std::declval<T*>(), + std::declval<Args&&>()...))>; + + template<class> + static char check(long); + +public: + BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1; +}; +#endif + +template<bool, class = void> +struct alloc_if { }; + +template<class T> +struct alloc_if<true, T> { + typedef T type; +}; + +} /* detail */ + #if defined(BOOST_NO_CXX11_ALLOCATOR) template<class A, class T> -inline void +inline typename detail::alloc_if<detail::alloc_has_construct<A>::value>::type +allocator_construct(A& a, T* p) +{ + a.construct(p); +} + +template<class A, class T> +inline typename detail::alloc_if<!detail::alloc_has_construct<A>::value>::type allocator_construct(A&, T* p) { ::new((void*)p) T(); @@ -467,24 +513,6 @@ allocator_construct(A&, T* p, V& v) } #endif #else -namespace detail { - -template<class A, class T, class... Args> -class alloc_has_construct { - template<class O> - static auto check(int) - -> alloc_no<decltype(std::declval<O&>().construct(std::declval<T*>(), - std::declval<Args&&>()...))>; - - template<class> - static char check(long); - -public: - BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1; -}; - -} /* detail */ - template<class A, class T, class... Args> inline typename std::enable_if<detail::alloc_has_construct<A, T, Args...>::value>::type @@ -502,17 +530,20 @@ allocator_construct(A&, T* p, Args&&... args) } #endif +namespace detail { + #if defined(BOOST_NO_CXX11_ALLOCATOR) +template<class A, class, class = void> +struct alloc_has_destroy { + BOOST_STATIC_CONSTEXPR bool value = false; +}; + template<class A, class T> -inline void -allocator_destroy(A&, T* p) -{ - p->~T(); - (void)p; -} +struct alloc_has_destroy<A, T, + typename alloc_void<typename A::_default_construct_destroy>::type> { + BOOST_STATIC_CONSTEXPR bool value = true; +}; #else -namespace detail { - template<class A, class T> class alloc_has_destroy { template<class O> @@ -525,24 +556,24 @@ class alloc_has_destroy { public: BOOST_STATIC_CONSTEXPR bool value = sizeof(check<A>(0)) > 1; }; +#endif } /* detail */ template<class A, class T> -inline typename std::enable_if<detail::alloc_has_destroy<A, T>::value>::type +inline typename detail::alloc_if<detail::alloc_has_destroy<A, T>::value>::type allocator_destroy(A& a, T* p) { a.destroy(p); } template<class A, class T> -inline typename std::enable_if<!detail::alloc_has_destroy<A, T>::value>::type +inline typename detail::alloc_if<!detail::alloc_has_destroy<A, T>::value>::type allocator_destroy(A&, T* p) { p->~T(); (void)p; } -#endif namespace detail { @@ -587,14 +618,6 @@ public: }; #endif -template<bool, class> -struct alloc_if { }; - -template<class T> -struct alloc_if<true, T> { - typedef T type; -}; - } /* detail */ template<class A> @@ -669,6 +692,75 @@ allocator_select_on_container_copy_construction(const A& a) return a; } +template<class A, class T> +inline void +allocator_destroy_n(A& a, T* p, std::size_t n) +{ + while (n > 0) { + boost::allocator_destroy(a, p + --n); + } +} + +namespace detail { + +template<class A, class T> +class alloc_destroyer { +public: + alloc_destroyer(A& a, T* p) BOOST_NOEXCEPT + : a_(a), p_(p), n_(0) { } + + ~alloc_destroyer() { + boost::allocator_destroy_n(a_, p_, n_); + } + + std::size_t& size() BOOST_NOEXCEPT { + return n_; + } + +private: + alloc_destroyer(const alloc_destroyer&); + alloc_destroyer& operator=(const alloc_destroyer&); + + A& a_; + T* p_; + std::size_t n_; +}; + +} /* detail */ + +template<class A, class T> +inline void +allocator_construct_n(A& a, T* p, std::size_t n) +{ + detail::alloc_destroyer<A, T> d(a, p); + for (std::size_t& i = d.size(); i < n; ++i) { + boost::allocator_construct(a, p + i); + } + d.size() = 0; +} + +template<class A, class T> +inline void +allocator_construct_n(A& a, T* p, std::size_t n, const T* l, std::size_t m) +{ + detail::alloc_destroyer<A, T> d(a, p); + for (std::size_t& i = d.size(); i < n; ++i) { + boost::allocator_construct(a, p + i, l[i % m]); + } + d.size() = 0; +} + +template<class A, class T, class I> +inline void +allocator_construct_n(A& a, T* p, std::size_t n, I b) +{ + detail::alloc_destroyer<A, T> d(a, p); + for (std::size_t& i = d.size(); i < n; void(++i), void(++b)) { + boost::allocator_construct(a, p + i, *b); + } + d.size() = 0; +} + #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) template<class A> using allocator_value_type_t = typename allocator_value_type<A>::type; diff --git a/contrib/restricted/boost/core/include/boost/core/bit.hpp b/contrib/restricted/boost/core/include/boost/core/bit.hpp index 1288979091..ddd435b0f4 100644 --- a/contrib/restricted/boost/core/include/boost/core/bit.hpp +++ b/contrib/restricted/boost/core/include/boost/core/bit.hpp @@ -171,15 +171,15 @@ int countl_zero( T x ) BOOST_NOEXCEPT { BOOST_STATIC_ASSERT( sizeof(T) == sizeof(boost::uint8_t) || sizeof(T) == sizeof(boost::uint16_t) || sizeof(T) == sizeof(boost::uint32_t) || sizeof(T) == sizeof(boost::uint64_t) ); - if( sizeof(T) == sizeof(boost::uint8_t) ) + BOOST_IF_CONSTEXPR ( sizeof(T) == sizeof(boost::uint8_t) ) { return boost::core::detail::countl_impl( static_cast<boost::uint8_t>( x ) ); } - else if( sizeof(T) == sizeof(boost::uint16_t) ) + else BOOST_IF_CONSTEXPR ( sizeof(T) == sizeof(boost::uint16_t) ) { return boost::core::detail::countl_impl( static_cast<boost::uint16_t>( x ) ); } - else if( sizeof(T) == sizeof(boost::uint32_t) ) + else BOOST_IF_CONSTEXPR ( sizeof(T) == sizeof(boost::uint32_t) ) { return boost::core::detail::countl_impl( static_cast<boost::uint32_t>( x ) ); } @@ -306,15 +306,15 @@ int countr_zero( T x ) BOOST_NOEXCEPT { BOOST_STATIC_ASSERT( sizeof(T) == sizeof(boost::uint8_t) || sizeof(T) == sizeof(boost::uint16_t) || sizeof(T) == sizeof(boost::uint32_t) || sizeof(T) == sizeof(boost::uint64_t) ); - if( sizeof(T) == sizeof(boost::uint8_t) ) + BOOST_IF_CONSTEXPR ( sizeof(T) == sizeof(boost::uint8_t) ) { return boost::core::detail::countr_impl( static_cast<boost::uint8_t>( x ) ); } - else if( sizeof(T) == sizeof(boost::uint16_t) ) + else BOOST_IF_CONSTEXPR ( sizeof(T) == sizeof(boost::uint16_t) ) { return boost::core::detail::countr_impl( static_cast<boost::uint16_t>( x ) ); } - else if( sizeof(T) == sizeof(boost::uint32_t) ) + else BOOST_IF_CONSTEXPR ( sizeof(T) == sizeof(boost::uint32_t) ) { return boost::core::detail::countr_impl( static_cast<boost::uint32_t>( x ) ); } @@ -410,7 +410,7 @@ BOOST_CXX14_CONSTEXPR int popcount( T x ) BOOST_NOEXCEPT { BOOST_STATIC_ASSERT( sizeof(T) <= sizeof(boost::uint64_t) ); - if( sizeof(T) <= sizeof(boost::uint32_t) ) + BOOST_IF_CONSTEXPR ( sizeof(T) <= sizeof(boost::uint32_t) ) { return boost::core::detail::popcount_impl( static_cast<boost::uint32_t>( x ) ); } @@ -512,7 +512,7 @@ BOOST_CXX14_CONSTEXPR T bit_ceil( T x ) BOOST_NOEXCEPT { BOOST_STATIC_ASSERT( sizeof(T) <= sizeof(boost::uint64_t) ); - if( sizeof(T) <= sizeof(boost::uint32_t) ) + BOOST_IF_CONSTEXPR ( sizeof(T) <= sizeof(boost::uint32_t) ) { return static_cast<T>( boost::core::detail::bit_ceil_impl( static_cast<boost::uint32_t>( x ) ) ); } diff --git a/contrib/restricted/boost/core/include/boost/core/noinit_adaptor.hpp b/contrib/restricted/boost/core/include/boost/core/noinit_adaptor.hpp index 962b6e42e7..623e3ea4b2 100644 --- a/contrib/restricted/boost/core/include/boost/core/noinit_adaptor.hpp +++ b/contrib/restricted/boost/core/include/boost/core/noinit_adaptor.hpp @@ -15,6 +15,8 @@ namespace boost { template<class A> struct noinit_adaptor : A { + typedef void _default_construct_destroy; + template<class U> struct rebind { typedef noinit_adaptor<typename allocator_rebind<A, U>::type> other; diff --git a/contrib/restricted/boost/core/include/boost/core/noncopyable.hpp b/contrib/restricted/boost/core/include/boost/core/noncopyable.hpp index 4a4f8baba5..4ec2d54fa8 100644 --- a/contrib/restricted/boost/core/include/boost/core/noncopyable.hpp +++ b/contrib/restricted/boost/core/include/boost/core/noncopyable.hpp @@ -27,7 +27,7 @@ namespace noncopyable_ // protection from unintended ADL // whether a type derives from noncopyable without needing the definition // of noncopyable itself. // -// The definition of base_token is macro-guarded so that Type Trais can +// The definition of base_token is macro-guarded so that Type Traits can // define it locally without including this header, to avoid a dependency // on Core. diff --git a/contrib/restricted/boost/core/include/boost/core/pointer_traits.hpp b/contrib/restricted/boost/core/include/boost/core/pointer_traits.hpp index 71c9df6900..7de7a8e97e 100644 --- a/contrib/restricted/boost/core/include/boost/core/pointer_traits.hpp +++ b/contrib/restricted/boost/core/include/boost/core/pointer_traits.hpp @@ -100,11 +100,19 @@ template<class T, class U, class = void> struct ptr_rebind : ptr_transform<T, U> { }; +#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) template<class T, class U> struct ptr_rebind<T, U, typename ptr_valid<typename T::template rebind<U> >::type> { typedef typename T::template rebind<U> type; }; +#else +template<class T, class U> +struct ptr_rebind<T, U, + typename ptr_valid<typename T::template rebind<U>::other>::type> { + typedef typename T::template rebind<U>::other type; +}; +#endif #if !defined(BOOST_NO_CXX11_DECLTYPE_N3276) template<class T, class E> @@ -219,7 +227,7 @@ struct pointer_traits<T*> #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) template<class U> - using rebind = typename rebind_to<U>::type*; + using rebind = typename rebind_to<U>::type; #endif }; |