aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/restricted/boost/dynamic_bitset
diff options
context:
space:
mode:
authorrobot-contrib <robot-contrib@yandex-team.com>2022-09-09 12:38:49 +0300
committerrobot-contrib <robot-contrib@yandex-team.com>2022-09-09 12:38:49 +0300
commitb2056a228c8bccee03004f6d591541dfdbe4070e (patch)
tree9aabdf13d1639a4f225c70ec0c89e5e88e8e2826 /contrib/restricted/boost/dynamic_bitset
parent246ca658add29b0073d6234d5f6612dfbb70047f (diff)
downloadydb-b2056a228c8bccee03004f6d591541dfdbe4070e.tar.gz
Update contrib/restricted/boost/dynamic_bitset to 1.80.0
Diffstat (limited to 'contrib/restricted/boost/dynamic_bitset')
-rw-r--r--contrib/restricted/boost/dynamic_bitset/LICENSE23
-rw-r--r--contrib/restricted/boost/dynamic_bitset/README.md34
-rw-r--r--contrib/restricted/boost/dynamic_bitset/include/boost/detail/dynamic_bitset.hpp241
-rw-r--r--contrib/restricted/boost/dynamic_bitset/include/boost/dynamic_bitset/config.hpp2
-rw-r--r--contrib/restricted/boost/dynamic_bitset/include/boost/dynamic_bitset/detail/dynamic_bitset.hpp307
-rw-r--r--contrib/restricted/boost/dynamic_bitset/include/boost/dynamic_bitset/detail/lowest_bit.hpp (renamed from contrib/restricted/boost/dynamic_bitset/include/boost/pending/lowest_bit.hpp)8
-rw-r--r--contrib/restricted/boost/dynamic_bitset/include/boost/dynamic_bitset/dynamic_bitset.hpp224
7 files changed, 569 insertions, 270 deletions
diff --git a/contrib/restricted/boost/dynamic_bitset/LICENSE b/contrib/restricted/boost/dynamic_bitset/LICENSE
new file mode 100644
index 0000000000..36b7cd93cd
--- /dev/null
+++ b/contrib/restricted/boost/dynamic_bitset/LICENSE
@@ -0,0 +1,23 @@
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/contrib/restricted/boost/dynamic_bitset/README.md b/contrib/restricted/boost/dynamic_bitset/README.md
new file mode 100644
index 0000000000..d63e2da5f7
--- /dev/null
+++ b/contrib/restricted/boost/dynamic_bitset/README.md
@@ -0,0 +1,34 @@
+DynamicBitset, part of collection of the [Boost C++ Libraries](http://github.com/boostorg), is similar to std::bitset however the size is specified at run-time instead of at compile-time.
+
+### License
+
+Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).
+
+### Properties
+
+* C++03
+* Header-only
+
+### Build Status
+
+Branch | GHA CI | Appveyor | Coverity Scan | codecov.io | Deps | Docs | Tests |
+:-------------: | ------ | -------- | ------------- | ---------- | ---- | ---- | ----- |
+[`master`](https://github.com/boostorg/dynamic_bitset/tree/master) | [![Build Status](https://github.com/boostorg/dynamic_bitset/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/boostorg/dynamic_bitset/actions?query=branch:master) | [![Build status](https://ci.appveyor.com/api/projects/status/keyn57y5d3sl1gw5/branch/master?svg=true)](https://ci.appveyor.com/project/jeking3/dynamic_bitset-jv17p/branch/master) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/16167/badge.svg)](https://scan.coverity.com/projects/boostorg-dynamic_bitset) | [![codecov](https://codecov.io/gh/boostorg/dynamic_bitset/branch/master/graph/badge.svg)](https://codecov.io/gh/boostorg/dynamic_bitset/branch/master)| [![Deps](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/dynamic_bitset.html) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](http://www.boost.org/doc/libs/master/doc/html/dynamic_bitset.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/dynamic_bitset.html)
+[`develop`](https://github.com/boostorg/dynamic_bitset/tree/develop) | [![Build Status](https://github.com/boostorg/dynamic_bitset/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/boostorg/dynamic_bitset/actions?query=branch:develop) | [![Build status](https://ci.appveyor.com/api/projects/status/keyn57y5d3sl1gw5/branch/develop?svg=true)](https://ci.appveyor.com/project/jeking3/dynamic_bitset-jv17p/branch/develop) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/16167/badge.svg)](https://scan.coverity.com/projects/boostorg-dynamic_bitset) | [![codecov](https://codecov.io/gh/boostorg/dynamic_bitset/branch/develop/graph/badge.svg)](https://codecov.io/gh/boostorg/dynamic_bitset/branch/develop) | [![Deps](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/dynamic_bitset.html) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](http://www.boost.org/doc/libs/develop/doc/html/dynamic_bitset.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/dynamic_bitset.html)
+
+### Directories
+
+| Name | Purpose |
+| ----------- | ------------------------------ |
+| `example` | examples |
+| `doc` | documentation |
+| `include` | headers |
+| `test` | unit tests |
+
+### More information
+
+* [Ask questions](http://stackoverflow.com/questions/ask?tags=c%2B%2B,boost,boost-dynamic_bitset)
+* [Report bugs](https://github.com/boostorg/dynamic_bitset/issues): Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well.
+* Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).
+* Discussions about the library are held on the [Boost developers mailing list](http://www.boost.org/community/groups.html#main). Be sure to read the [discussion policy](http://www.boost.org/community/policy.html) before posting and add the `[dynamic_bitset]` tag at the beginning of the subject line.
+
diff --git a/contrib/restricted/boost/dynamic_bitset/include/boost/detail/dynamic_bitset.hpp b/contrib/restricted/boost/dynamic_bitset/include/boost/detail/dynamic_bitset.hpp
deleted file mode 100644
index e0f675d5ec..0000000000
--- a/contrib/restricted/boost/dynamic_bitset/include/boost/detail/dynamic_bitset.hpp
+++ /dev/null
@@ -1,241 +0,0 @@
-// -----------------------------------------------------------
-//
-// Copyright (c) 2001-2002 Chuck Allison and Jeremy Siek
-// Copyright (c) 2003-2006, 2008 Gennaro Prota
-//
-// Copyright (c) 2014 Glen Joseph Fernandes
-// glenfe at live dot com
-//
-// 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_DETAIL_DYNAMIC_BITSET_HPP
-#define BOOST_DETAIL_DYNAMIC_BITSET_HPP
-
-#include <memory>
-#include <cstddef>
-#include "boost/config.hpp"
-#include "boost/detail/workaround.hpp"
-
-
-namespace boost {
-
- namespace detail {
- namespace dynamic_bitset_impl {
-
- // Gives (read-)access to the object representation
- // of an object of type T (3.9p4). CANNOT be used
- // on a base sub-object
- //
- template <typename T>
- inline const unsigned char * object_representation (T* p)
- {
- return static_cast<const unsigned char *>(static_cast<const void *>(p));
- }
-
- template<typename T, int amount, int width /* = default */>
- struct shifter
- {
- static void left_shift(T & v) {
- amount >= width ? (v = 0)
- : (v >>= BOOST_DYNAMIC_BITSET_WRAP_CONSTANT(amount));
- }
- };
-
- // ------- count function implementation --------------
-
- typedef unsigned char byte_type;
-
- // These two entities
- //
- // enum mode { access_by_bytes, access_by_blocks };
- // template <mode> struct mode_to_type {};
- //
- // were removed, since the regression logs (as of 24 Aug 2008)
- // showed that several compilers had troubles with recognizing
- //
- // const mode m = access_by_bytes
- //
- // as a constant expression
- //
- // * So, we'll use bool, instead of enum *.
- //
- template <bool value>
- struct value_to_type
- {
- value_to_type() {}
- };
- const bool access_by_bytes = true;
- const bool access_by_blocks = false;
-
-
- // the table: wrapped in a class template, so
- // that it is only instantiated if/when needed
- //
- template <bool dummy_name = true>
- struct count_table { static const byte_type table[]; };
-
- template <>
- struct count_table<false> { /* no table */ };
-
-
- const unsigned int table_width = 8;
- template <bool b>
- const byte_type count_table<b>::table[] =
- {
- // Automatically generated by GPTableGen.exe v.1.0
- //
- 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
- 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
- };
-
-
- // overload for access by bytes
- //
-
- template <typename Iterator>
- inline std::size_t do_count(Iterator first, std::size_t length,
- int /*dummy param*/,
- value_to_type<access_by_bytes>* )
- {
- std::size_t num = 0;
- if (length)
- {
- const byte_type * p = object_representation(&*first);
- length *= sizeof(*first);
-
- do {
- num += count_table<>::table[*p];
- ++p;
- --length;
-
- } while (length);
- }
-
- return num;
- }
-
-
- // overload for access by blocks
- //
- template <typename Iterator, typename ValueType>
- inline std::size_t do_count(Iterator first, std::size_t length, ValueType,
- value_to_type<access_by_blocks>*)
- {
- std::size_t num = 0;
- while (length){
-
- ValueType value = *first;
- while (value) {
- num += count_table<>::table[value & ((1u<<table_width) - 1)];
- value >>= table_width;
- }
-
- ++first;
- --length;
- }
-
- return num;
- }
-
- // -------------------------------------------------------
-
-
- // Some library implementations simply return a dummy
- // value such as
- //
- // size_type(-1) / sizeof(T)
- //
- // from vector<>::max_size. This tries to get more
- // meaningful info.
- //
- template <typename T>
- inline typename T::size_type vector_max_size_workaround(const T & v)
- BOOST_NOEXCEPT
- {
- typedef typename T::allocator_type allocator_type;
-
- const allocator_type& alloc = v.get_allocator();
-
-#if !defined(BOOST_NO_CXX11_ALLOCATOR)
- typedef std::allocator_traits<allocator_type> allocator_traits;
-
- const typename allocator_traits::size_type alloc_max =
- allocator_traits::max_size(alloc);
-#else
- const typename allocator_type::size_type alloc_max = alloc.max_size();
-#endif
-
- const typename T::size_type container_max = v.max_size();
-
- return alloc_max < container_max ? alloc_max : container_max;
- }
-
- // for static_asserts
- template <typename T>
- struct allowed_block_type {
- enum { value = T(-1) > 0 }; // ensure T has no sign
- };
-
- template <>
- struct allowed_block_type<bool> {
- enum { value = false };
- };
-
-
- template <typename T>
- struct is_numeric {
- enum { value = false };
- };
-
-# define BOOST_dynamic_bitset_is_numeric(x) \
- template<> \
- struct is_numeric< x > { \
- enum { value = true }; \
- } /**/
-
- BOOST_dynamic_bitset_is_numeric(bool);
- BOOST_dynamic_bitset_is_numeric(char);
-
-#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
- BOOST_dynamic_bitset_is_numeric(wchar_t);
-#endif
-
- BOOST_dynamic_bitset_is_numeric(signed char);
- BOOST_dynamic_bitset_is_numeric(short int);
- BOOST_dynamic_bitset_is_numeric(int);
- BOOST_dynamic_bitset_is_numeric(long int);
-
- BOOST_dynamic_bitset_is_numeric(unsigned char);
- BOOST_dynamic_bitset_is_numeric(unsigned short);
- BOOST_dynamic_bitset_is_numeric(unsigned int);
- BOOST_dynamic_bitset_is_numeric(unsigned long);
-
-#if defined(BOOST_HAS_LONG_LONG)
- BOOST_dynamic_bitset_is_numeric(::boost::long_long_type);
- BOOST_dynamic_bitset_is_numeric(::boost::ulong_long_type);
-#endif
-
- // intentionally omitted
- //BOOST_dynamic_bitset_is_numeric(float);
- //BOOST_dynamic_bitset_is_numeric(double);
- //BOOST_dynamic_bitset_is_numeric(long double);
-
-#undef BOOST_dynamic_bitset_is_numeric
-
- } // dynamic_bitset_impl
- } // namespace detail
-
-} // namespace boost
-
-#endif // include guard
-
diff --git a/contrib/restricted/boost/dynamic_bitset/include/boost/dynamic_bitset/config.hpp b/contrib/restricted/boost/dynamic_bitset/include/boost/dynamic_bitset/config.hpp
index 1e6d9f7e47..ade19d47ac 100644
--- a/contrib/restricted/boost/dynamic_bitset/include/boost/dynamic_bitset/config.hpp
+++ b/contrib/restricted/boost/dynamic_bitset/include/boost/dynamic_bitset/config.hpp
@@ -34,7 +34,7 @@ namespace boost { namespace detail {
#endif
//
-#if (defined __BORLANDC__ && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))) \
+#if (defined BOOST_BORLANDC && BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))) \
|| (defined BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
#define BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS
#endif
diff --git a/contrib/restricted/boost/dynamic_bitset/include/boost/dynamic_bitset/detail/dynamic_bitset.hpp b/contrib/restricted/boost/dynamic_bitset/include/boost/dynamic_bitset/detail/dynamic_bitset.hpp
new file mode 100644
index 0000000000..538f2457ac
--- /dev/null
+++ b/contrib/restricted/boost/dynamic_bitset/include/boost/dynamic_bitset/detail/dynamic_bitset.hpp
@@ -0,0 +1,307 @@
+// -----------------------------------------------------------
+//
+// Copyright (c) 2001-2002 Chuck Allison and Jeremy Siek
+// Copyright (c) 2003-2006, 2008 Gennaro Prota
+// Copyright (c) 2014 Glen Joseph Fernandes
+// (glenjofe@gmail.com)
+// Copyright (c) 2018 Evgeny Shulgin
+// Copyright (c) 2019 Andrey Semashev
+//
+// 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_DETAIL_DYNAMIC_BITSET_HPP
+#define BOOST_DETAIL_DYNAMIC_BITSET_HPP
+
+#include <memory>
+#include <cstddef>
+#include "boost/config.hpp"
+#include "boost/detail/workaround.hpp"
+#include <boost/core/allocator_access.hpp>
+
+#if ((defined(BOOST_MSVC) && (BOOST_MSVC >= 1600)) || (defined(__clang__) && defined(__c2__)) || (defined(BOOST_INTEL) && defined(_MSC_VER))) && (defined(_M_IX86) || defined(_M_X64))
+#include <intrin.h>
+#endif
+
+namespace boost {
+
+ namespace detail {
+ namespace dynamic_bitset_impl {
+
+ template<class T>
+ struct max_limit {
+ BOOST_STATIC_CONSTEXPR T value = static_cast<T>(-1);
+ };
+
+ template<class T>
+ BOOST_CONSTEXPR_OR_CONST T max_limit<T>::value;
+
+ // Gives (read-)access to the object representation
+ // of an object of type T (3.9p4). CANNOT be used
+ // on a base sub-object
+ //
+ template <typename T>
+ inline const unsigned char * object_representation (T* p)
+ {
+ return static_cast<const unsigned char *>(static_cast<const void *>(p));
+ }
+
+ template<typename T, int amount, int width /* = default */>
+ struct shifter
+ {
+ static void left_shift(T & v) {
+ amount >= width ? (v = 0)
+ : (v >>= BOOST_DYNAMIC_BITSET_WRAP_CONSTANT(amount));
+ }
+ };
+
+ // ------- count function implementation --------------
+
+ typedef unsigned char byte_type;
+
+ // These two entities
+ //
+ // enum mode { access_by_bytes, access_by_blocks };
+ // template <mode> struct mode_to_type {};
+ //
+ // were removed, since the regression logs (as of 24 Aug 2008)
+ // showed that several compilers had troubles with recognizing
+ //
+ // const mode m = access_by_bytes
+ //
+ // as a constant expression
+ //
+ // * So, we'll use bool, instead of enum *.
+ //
+ template <bool value>
+ struct value_to_type
+ {
+ value_to_type() {}
+ };
+ const bool access_by_bytes = true;
+ const bool access_by_blocks = false;
+
+
+ // the table: wrapped in a class template, so
+ // that it is only instantiated if/when needed
+ //
+ template <bool dummy_name = true>
+ struct count_table { static const byte_type table[]; };
+
+ template <>
+ struct count_table<false> { /* no table */ };
+
+
+ const unsigned int table_width = 8;
+ template <bool b>
+ const byte_type count_table<b>::table[] =
+ {
+ // Automatically generated by GPTableGen.exe v.1.0
+ //
+ 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
+ 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+ 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+ 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+ 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
+ };
+
+
+ // Some platforms have fast popcount operation, that allow us to implement
+ // counting bits much more efficiently
+ //
+ template <typename ValueType>
+ BOOST_FORCEINLINE std::size_t popcount(ValueType value) BOOST_NOEXCEPT
+ {
+ std::size_t num = 0u;
+ while (value) {
+ num += count_table<>::table[value & ((1u<<table_width) - 1)];
+ value >>= table_width;
+ }
+ return num;
+ }
+
+#if (((defined(BOOST_MSVC) && (BOOST_MSVC >= 1600)) || (defined(__clang__) && defined(__c2__)) || (defined(BOOST_INTEL) && defined(_MSC_VER))) && (defined(_M_IX86) || defined(_M_X64))) \
+ && (defined(__POPCNT__) || defined(__AVX__))
+
+ template <>
+ BOOST_FORCEINLINE std::size_t popcount<unsigned short>(unsigned short value) BOOST_NOEXCEPT
+ {
+ return static_cast<std::size_t>(__popcnt16(value));
+ }
+
+ template <>
+ BOOST_FORCEINLINE std::size_t popcount<unsigned int>(unsigned int value) BOOST_NOEXCEPT
+ {
+ return static_cast<std::size_t>(__popcnt(value));
+ }
+
+ template <>
+ BOOST_FORCEINLINE std::size_t popcount<unsigned __int64>(unsigned __int64 value) BOOST_NOEXCEPT
+ {
+#if defined(_M_X64)
+ return static_cast<std::size_t>(__popcnt64(value));
+#else
+ return static_cast<std::size_t>(__popcnt(static_cast< unsigned int >(value))) + static_cast<std::size_t>(__popcnt(static_cast< unsigned int >(value >> 32)));
+#endif
+ }
+
+#elif defined(BOOST_GCC) || defined(__clang__) || (defined(BOOST_INTEL) && defined(__GNUC__))
+
+ // Note: gcc builtins are implemented by compiler runtime when the target CPU may not support the necessary instructions
+ template <>
+ BOOST_FORCEINLINE std::size_t popcount<unsigned short>(unsigned short value) BOOST_NOEXCEPT
+ {
+ return static_cast<unsigned int>(__builtin_popcount(static_cast<unsigned int>(value)));
+ }
+
+ template <>
+ BOOST_FORCEINLINE std::size_t popcount<unsigned int>(unsigned int value) BOOST_NOEXCEPT
+ {
+ return static_cast<unsigned int>(__builtin_popcount(value));
+ }
+
+ template <>
+ BOOST_FORCEINLINE std::size_t popcount<unsigned long>(unsigned long value) BOOST_NOEXCEPT
+ {
+ return static_cast<unsigned int>(__builtin_popcountl(value));
+ }
+
+ template <>
+ BOOST_FORCEINLINE std::size_t popcount<boost::ulong_long_type>(boost::ulong_long_type value) BOOST_NOEXCEPT
+ {
+ return static_cast<unsigned int>(__builtin_popcountll(value));
+ }
+
+#endif
+
+ // overload for access by blocks
+ //
+ template <typename Iterator, typename ValueType>
+ inline std::size_t do_count(Iterator first, std::size_t length, ValueType,
+ value_to_type<access_by_blocks>*)
+ {
+ std::size_t num1 = 0u, num2 = 0u;
+ while (length >= 2u) {
+ num1 += popcount<ValueType>(*first);
+ ++first;
+ num2 += popcount<ValueType>(*first);
+ ++first;
+ length -= 2u;
+ }
+
+ if (length > 0u)
+ num1 += popcount<ValueType>(*first);
+
+ return num1 + num2;
+ }
+
+ // overload for access by bytes
+ //
+ template <typename Iterator>
+ inline std::size_t do_count(Iterator first, std::size_t length,
+ int /*dummy param*/,
+ value_to_type<access_by_bytes>*)
+ {
+ if (length > 0u) {
+ const byte_type* p = object_representation(&*first);
+ length *= sizeof(*first);
+
+ return do_count(p, length, static_cast<byte_type>(0u),
+ static_cast< value_to_type<access_by_blocks>* >(0));
+ }
+
+ return 0u;
+ }
+
+ // -------------------------------------------------------
+
+
+ // Some library implementations simply return a dummy
+ // value such as
+ //
+ // size_type(-1) / sizeof(T)
+ //
+ // from vector<>::max_size. This tries to get more
+ // meaningful info.
+ //
+ template <typename T>
+ inline typename T::size_type vector_max_size_workaround(const T & v)
+ BOOST_NOEXCEPT
+ {
+ typedef typename T::allocator_type allocator_type;
+
+ const allocator_type& alloc = v.get_allocator();
+
+ typename boost::allocator_size_type<allocator_type>::type alloc_max =
+ boost::allocator_max_size(alloc);
+
+ const typename T::size_type container_max = v.max_size();
+
+ return alloc_max < container_max ? alloc_max : container_max;
+ }
+
+ // for static_asserts
+ template <typename T>
+ struct allowed_block_type {
+ enum { value = T(-1) > 0 }; // ensure T has no sign
+ };
+
+ template <>
+ struct allowed_block_type<bool> {
+ enum { value = false };
+ };
+
+
+ template <typename T>
+ struct is_numeric {
+ enum { value = false };
+ };
+
+# define BOOST_dynamic_bitset_is_numeric(x) \
+ template<> \
+ struct is_numeric< x > { \
+ enum { value = true }; \
+ } /**/
+
+ BOOST_dynamic_bitset_is_numeric(bool);
+ BOOST_dynamic_bitset_is_numeric(char);
+
+#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
+ BOOST_dynamic_bitset_is_numeric(wchar_t);
+#endif
+
+ BOOST_dynamic_bitset_is_numeric(signed char);
+ BOOST_dynamic_bitset_is_numeric(short int);
+ BOOST_dynamic_bitset_is_numeric(int);
+ BOOST_dynamic_bitset_is_numeric(long int);
+
+ BOOST_dynamic_bitset_is_numeric(unsigned char);
+ BOOST_dynamic_bitset_is_numeric(unsigned short);
+ BOOST_dynamic_bitset_is_numeric(unsigned int);
+ BOOST_dynamic_bitset_is_numeric(unsigned long);
+
+#if defined(BOOST_HAS_LONG_LONG)
+ BOOST_dynamic_bitset_is_numeric(::boost::long_long_type);
+ BOOST_dynamic_bitset_is_numeric(::boost::ulong_long_type);
+#endif
+
+ // intentionally omitted
+ //BOOST_dynamic_bitset_is_numeric(float);
+ //BOOST_dynamic_bitset_is_numeric(double);
+ //BOOST_dynamic_bitset_is_numeric(long double);
+
+#undef BOOST_dynamic_bitset_is_numeric
+
+ } // dynamic_bitset_impl
+ } // namespace detail
+
+} // namespace boost
+
+#endif // include guard
+
diff --git a/contrib/restricted/boost/dynamic_bitset/include/boost/pending/lowest_bit.hpp b/contrib/restricted/boost/dynamic_bitset/include/boost/dynamic_bitset/detail/lowest_bit.hpp
index 697f6d070f..42f6fb6174 100644
--- a/contrib/restricted/boost/dynamic_bitset/include/boost/pending/lowest_bit.hpp
+++ b/contrib/restricted/boost/dynamic_bitset/include/boost/dynamic_bitset/detail/lowest_bit.hpp
@@ -14,16 +14,16 @@
#ifndef BOOST_LOWEST_BIT_HPP_GP_20030301
#define BOOST_LOWEST_BIT_HPP_GP_20030301
-#include <assert.h>
#include "boost/integer/integer_log2.hpp"
-
+#include "boost/assert.hpp"
namespace boost {
+namespace detail {
template <typename T>
int lowest_bit(T x) {
- assert(x >= 1); // PRE
+ BOOST_ASSERT(x >= 1); // PRE
// clear all bits on except the rightmost one,
// then calculate the logarithm base 2
@@ -32,7 +32,7 @@ namespace boost {
}
-
+}
}
diff --git a/contrib/restricted/boost/dynamic_bitset/include/boost/dynamic_bitset/dynamic_bitset.hpp b/contrib/restricted/boost/dynamic_bitset/include/boost/dynamic_bitset/dynamic_bitset.hpp
index 83fcb61a1e..7c96f0905e 100644
--- a/contrib/restricted/boost/dynamic_bitset/include/boost/dynamic_bitset/dynamic_bitset.hpp
+++ b/contrib/restricted/boost/dynamic_bitset/include/boost/dynamic_bitset/dynamic_bitset.hpp
@@ -5,8 +5,10 @@
// Copyright (c) 2014 Ahmed Charles
//
// Copyright (c) 2014 Glen Joseph Fernandes
-// glenfe at live dot com
+// (glenjofe@gmail.com)
+//
// Copyright (c) 2014 Riccardo Marcangelo
+// Copyright (c) 2018 Evgeny Shulgin
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -21,6 +23,7 @@
#include <string>
#include <stdexcept>
#include <algorithm>
+#include <iterator> // used to implement append(Iter, Iter)
#include <vector>
#include <climits> // for CHAR_BIT
@@ -39,15 +42,15 @@
#endif
#include "boost/dynamic_bitset_fwd.hpp"
-#include "boost/detail/dynamic_bitset.hpp"
-#include "boost/detail/iterator.hpp" // used to implement append(Iter, Iter)
+#include "boost/dynamic_bitset/detail/dynamic_bitset.hpp"
+#include "boost/dynamic_bitset/detail/lowest_bit.hpp"
#include "boost/move/move.hpp"
#include "boost/limits.hpp"
-#include "boost/pending/lowest_bit.hpp"
#include "boost/static_assert.hpp"
-#include "boost/utility/addressof.hpp"
-#include "boost/detail/no_exceptions_support.hpp"
+#include "boost/core/addressof.hpp"
+#include "boost/core/no_exceptions_support.hpp"
#include "boost/throw_exception.hpp"
+#include "boost/functional/hash/hash.hpp"
namespace boost {
@@ -125,8 +128,10 @@ public:
typedef bool const_reference;
// constructors, etc.
+ dynamic_bitset() : m_num_bits(0) {}
+
explicit
- dynamic_bitset(const Allocator& alloc = Allocator());
+ dynamic_bitset(const Allocator& alloc);
explicit
dynamic_bitset(size_type num_bits, unsigned long value = 0,
@@ -242,7 +247,7 @@ public:
{
assert(first != last);
block_width_type r = count_extra_bits();
- std::size_t d = boost::detail::distance(first, last);
+ std::size_t d = std::distance(first, last);
m_bits.reserve(num_blocks() + d);
if (r == 0) {
for( ; first != last; ++first)
@@ -262,7 +267,7 @@ public:
void append(BlockInputIterator first, BlockInputIterator last) // strong guarantee
{
if (first != last) {
- typename detail::iterator_traits<BlockInputIterator>::iterator_category cat;
+ typename std::iterator_traits<BlockInputIterator>::iterator_category cat;
m_append(first, last, cat);
}
}
@@ -279,10 +284,13 @@ public:
dynamic_bitset operator>>(size_type n) const;
// basic bit operations
+ dynamic_bitset& set(size_type n, size_type len, bool val /* = true */); // default would make it ambiguous
dynamic_bitset& set(size_type n, bool val = true);
dynamic_bitset& set();
+ dynamic_bitset& reset(size_type n, size_type len);
dynamic_bitset& reset(size_type n);
dynamic_bitset& reset();
+ dynamic_bitset& flip(size_type n, size_type len);
dynamic_bitset& flip(size_type n);
dynamic_bitset& flip();
bool test(size_type n) const;
@@ -349,7 +357,8 @@ public:
template <typename B, typename A, typename stringT>
friend void to_string_helper(const dynamic_bitset<B, A> & b, stringT & s, bool dump_all);
-
+ template <typename B, typename A>
+ friend std::size_t hash_value(const dynamic_bitset<B, A>& a);
#endif
public:
@@ -360,15 +369,64 @@ public:
private:
BOOST_STATIC_CONSTANT(block_width_type, ulong_width = std::numeric_limits<unsigned long>::digits);
+ dynamic_bitset& range_operation(size_type pos, size_type len,
+ Block (*partial_block_operation)(Block, size_type, size_type),
+ Block (*full_block_operation)(Block));
void m_zero_unused_bits();
bool m_check_invariants() const;
+ static bool m_not_empty(Block x){ return x != Block(0); };
size_type m_do_find_from(size_type first_block) const;
block_width_type count_extra_bits() const BOOST_NOEXCEPT { return bit_index(size()); }
static size_type block_index(size_type pos) BOOST_NOEXCEPT { return pos / bits_per_block; }
static block_width_type bit_index(size_type pos) BOOST_NOEXCEPT { return static_cast<block_width_type>(pos % bits_per_block); }
static Block bit_mask(size_type pos) BOOST_NOEXCEPT { return Block(1) << bit_index(pos); }
+ static Block bit_mask(size_type first, size_type last) BOOST_NOEXCEPT
+ {
+ Block res = (last == bits_per_block - 1)
+ ? detail::dynamic_bitset_impl::max_limit<Block>::value
+ : ((Block(1) << (last + 1)) - 1);
+ res ^= (Block(1) << first) - 1;
+ return res;
+ }
+ static Block set_block_bits(Block block, size_type first,
+ size_type last, bool val) BOOST_NOEXCEPT
+ {
+ if (val)
+ return block | bit_mask(first, last);
+ else
+ return block & static_cast<Block>(~bit_mask(first, last));
+ }
+
+ // Functions for operations on ranges
+ inline static Block set_block_partial(Block block, size_type first,
+ size_type last) BOOST_NOEXCEPT
+ {
+ return set_block_bits(block, first, last, true);
+ }
+ inline static Block set_block_full(Block) BOOST_NOEXCEPT
+ {
+ return detail::dynamic_bitset_impl::max_limit<Block>::value;
+ }
+ inline static Block reset_block_partial(Block block, size_type first,
+ size_type last) BOOST_NOEXCEPT
+ {
+ return set_block_bits(block, first, last, false);
+ }
+ inline static Block reset_block_full(Block) BOOST_NOEXCEPT
+ {
+ return 0;
+ }
+ inline static Block flip_block_partial(Block block, size_type first,
+ size_type last) BOOST_NOEXCEPT
+ {
+ return block ^ bit_mask(first, last);
+ }
+ inline static Block flip_block_full(Block block) BOOST_NOEXCEPT
+ {
+ return ~block;
+ }
template <typename CharT, typename Traits, typename Alloc>
void init_from_string(const std::basic_string<CharT, Traits, Alloc>& s,
@@ -707,7 +765,7 @@ resize(size_type num_bits, bool value) // strong guarantee
const size_type old_num_blocks = num_blocks();
const size_type required_blocks = calc_num_blocks(num_bits);
- const block_type v = value? ~Block(0) : Block(0);
+ const block_type v = value? detail::dynamic_bitset_impl::max_limit<Block>::value : Block(0);
if (required_blocks != old_num_blocks) {
m_bits.resize(required_blocks, v); // s.g. (copy)
@@ -961,6 +1019,17 @@ dynamic_bitset<Block, Allocator>::operator>>(size_type n) const
template <typename Block, typename Allocator>
dynamic_bitset<Block, Allocator>&
+dynamic_bitset<Block, Allocator>::set(size_type pos,
+ size_type len, bool val)
+{
+ if (val)
+ return range_operation(pos, len, set_block_partial, set_block_full);
+ else
+ return range_operation(pos, len, reset_block_partial, reset_block_full);
+}
+
+template <typename Block, typename Allocator>
+dynamic_bitset<Block, Allocator>&
dynamic_bitset<Block, Allocator>::set(size_type pos, bool val)
{
assert(pos < m_num_bits);
@@ -977,12 +1046,19 @@ template <typename Block, typename Allocator>
dynamic_bitset<Block, Allocator>&
dynamic_bitset<Block, Allocator>::set()
{
- std::fill(m_bits.begin(), m_bits.end(), static_cast<Block>(~0));
+ std::fill(m_bits.begin(), m_bits.end(), detail::dynamic_bitset_impl::max_limit<Block>::value);
m_zero_unused_bits();
return *this;
}
template <typename Block, typename Allocator>
+inline dynamic_bitset<Block, Allocator>&
+dynamic_bitset<Block, Allocator>::reset(size_type pos, size_type len)
+{
+ return range_operation(pos, len, reset_block_partial, reset_block_full);
+}
+
+template <typename Block, typename Allocator>
dynamic_bitset<Block, Allocator>&
dynamic_bitset<Block, Allocator>::reset(size_type pos)
{
@@ -1008,6 +1084,13 @@ dynamic_bitset<Block, Allocator>::reset()
template <typename Block, typename Allocator>
dynamic_bitset<Block, Allocator>&
+dynamic_bitset<Block, Allocator>::flip(size_type pos, size_type len)
+{
+ return range_operation(pos, len, flip_block_partial, flip_block_full);
+}
+
+template <typename Block, typename Allocator>
+dynamic_bitset<Block, Allocator>&
dynamic_bitset<Block, Allocator>::flip(size_type pos)
{
assert(pos < m_num_bits);
@@ -1056,7 +1139,7 @@ bool dynamic_bitset<Block, Allocator>::all() const
}
const block_width_type extra_bits = count_extra_bits();
- block_type const all_ones = static_cast<Block>(~0);
+ block_type const all_ones = detail::dynamic_bitset_impl::max_limit<Block>::value;
if (extra_bits == 0) {
for (size_type i = 0, e = num_blocks(); i < e; ++i) {
@@ -1125,7 +1208,17 @@ dynamic_bitset<Block, Allocator>::count() const BOOST_NOEXCEPT
enum { enough_table_width = table_width >= CHAR_BIT };
- enum { mode = (no_padding && enough_table_width)
+#if ((defined(BOOST_MSVC) && (BOOST_MSVC >= 1600)) || (defined(__clang__) && defined(__c2__)) || (defined(BOOST_INTEL) && defined(_MSC_VER))) && (defined(_M_IX86) || defined(_M_X64))
+ // Windows popcount is effective starting from the unsigned short type
+ enum { uneffective_popcount = sizeof(Block) < sizeof(unsigned short) };
+#elif defined(BOOST_GCC) || defined(__clang__) || (defined(BOOST_INTEL) && defined(__GNUC__))
+ // GCC popcount is effective starting from the unsigned int type
+ enum { uneffective_popcount = sizeof(Block) < sizeof(unsigned int) };
+#else
+ enum { uneffective_popcount = true };
+#endif
+
+ enum { mode = (no_padding && enough_table_width && uneffective_popcount)
? access_by_bytes
: access_by_blocks };
@@ -1346,25 +1439,22 @@ bool dynamic_bitset<Block, Allocator>::intersects(const dynamic_bitset & b) cons
// --------------------------------
// lookup
-
// look for the first bit "on", starting
// from the block with index first_block
//
+
template <typename Block, typename Allocator>
typename dynamic_bitset<Block, Allocator>::size_type
dynamic_bitset<Block, Allocator>::m_do_find_from(size_type first_block) const
{
- size_type i = first_block;
- // skip null blocks
- while (i < num_blocks() && m_bits[i] == 0)
- ++i;
+ size_type i = std::distance(m_bits.begin(),
+ std::find_if(m_bits.begin() + first_block, m_bits.end(), m_not_empty) );
if (i >= num_blocks())
return npos; // not found
- return i * bits_per_block + static_cast<size_type>(boost::lowest_bit(m_bits[i]));
-
+ return i * bits_per_block + static_cast<size_type>(detail::lowest_bit(m_bits[i]));
}
@@ -1394,7 +1484,7 @@ dynamic_bitset<Block, Allocator>::find_next(size_type pos) const
const Block fore = m_bits[blk] >> ind;
return fore?
- pos + static_cast<size_type>(lowest_bit(fore))
+ pos + static_cast<size_type>(detail::lowest_bit(fore))
:
m_do_find_from(blk + 1);
@@ -1537,6 +1627,17 @@ inline bool operator>=(const dynamic_bitset<Block, Allocator>& a,
}
//-----------------------------------------------------------------------------
+// hash operations
+
+template <typename Block, typename Allocator>
+inline std::size_t hash_value(const dynamic_bitset<Block, Allocator>& a)
+{
+ std::size_t res = hash_value(a.m_num_bits);
+ boost::hash_combine(res, a.m_bits);
+ return res;
+}
+
+//-----------------------------------------------------------------------------
// stream operations
#ifdef BOOST_OLD_IOSTREAMS
@@ -1925,6 +2026,63 @@ inline const Block& dynamic_bitset<Block, Allocator>::m_highest_block() const
return m_bits.back();
}
+template <typename Block, typename Allocator>
+dynamic_bitset<Block, Allocator>& dynamic_bitset<Block, Allocator>::range_operation(
+ size_type pos, size_type len,
+ Block (*partial_block_operation)(Block, size_type, size_type),
+ Block (*full_block_operation)(Block))
+{
+ assert(pos + len <= m_num_bits);
+
+ // Do nothing in case of zero length
+ if (!len)
+ return *this;
+
+ // Use an additional asserts in order to detect size_type overflow
+ // For example: pos = 10, len = size_type_limit - 2, pos + len = 7
+ // In case of overflow, 'pos + len' is always smaller than 'len'
+ assert(pos + len >= len);
+
+ // Start and end blocks of the [pos; pos + len - 1] sequence
+ const size_type first_block = block_index(pos);
+ const size_type last_block = block_index(pos + len - 1);
+
+ const size_type first_bit_index = bit_index(pos);
+ const size_type last_bit_index = bit_index(pos + len - 1);
+
+ if (first_block == last_block) {
+ // Filling only a sub-block of a block
+ m_bits[first_block] = partial_block_operation(m_bits[first_block],
+ first_bit_index, last_bit_index);
+ } else {
+ // Check if the corner blocks won't be fully filled with 'val'
+ const size_type first_block_shift = bit_index(pos) ? 1 : 0;
+ const size_type last_block_shift = (bit_index(pos + len - 1)
+ == bits_per_block - 1) ? 0 : 1;
+
+ // Blocks that will be filled with ~0 or 0 at once
+ const size_type first_full_block = first_block + first_block_shift;
+ const size_type last_full_block = last_block - last_block_shift;
+
+ for (size_type i = first_full_block; i <= last_full_block; ++i) {
+ m_bits[i] = full_block_operation(m_bits[i]);
+ }
+
+ // Fill the first block from the 'first' bit index to the end
+ if (first_block_shift) {
+ m_bits[first_block] = partial_block_operation(m_bits[first_block],
+ first_bit_index, bits_per_block - 1);
+ }
+
+ // Fill the last block from the start to the 'last' bit index
+ if (last_block_shift) {
+ m_bits[last_block] = partial_block_operation(m_bits[last_block],
+ 0, last_bit_index);
+ }
+ }
+
+ return *this;
+}
// If size() is not a multiple of bits_per_block
// then not all the bits in the last block are used.
@@ -1949,7 +2107,7 @@ bool dynamic_bitset<Block, Allocator>::m_check_invariants() const
{
const block_width_type extra_bits = count_extra_bits();
if (extra_bits > 0) {
- const block_type mask = block_type(~0) << extra_bits;
+ const block_type mask = detail::dynamic_bitset_impl::max_limit<Block>::value << extra_bits;
if ((m_highest_block() & mask) != 0)
return false;
}
@@ -1963,8 +2121,26 @@ bool dynamic_bitset<Block, Allocator>::m_check_invariants() const
} // namespace boost
-
#undef BOOST_BITSET_CHAR
+// std::hash support
+#if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL) && !defined(BOOST_DYNAMIC_BITSET_NO_STD_HASH)
+#include <functional>
+namespace std
+{
+ template<typename Block, typename Allocator>
+ struct hash< boost::dynamic_bitset<Block, Allocator> >
+ {
+ typedef boost::dynamic_bitset<Block, Allocator> argument_type;
+ typedef std::size_t result_type;
+ result_type operator()(const argument_type& a) const BOOST_NOEXCEPT
+ {
+ boost::hash<argument_type> hasher;
+ return hasher(a);
+ }
+ };
+}
+#endif
+
#endif // include guard