From 111efe1eb32dcc562ee1abe9cacc4fe69c6b4e4e Mon Sep 17 00:00:00 2001 From: Zach Laine Date: Sat, 19 Sep 2020 22:27:47 -0500 Subject: [PATCH] Fully internalize Boost.Text headers. --- example/json.hpp | 4 +- include/boost/parser/concepts.hpp | 2 +- include/boost/parser/config.hpp | 2 + include/boost/parser/detail/debug_assert.hpp | 17 + include/boost/parser/detail/numeric.hpp | 4 +- include/boost/parser/detail/printing.hpp | 2 +- .../{ => parser/detail}/text/algorithm.hpp | 8 +- .../{ => parser/detail}/text/concepts.hpp | 12 +- include/boost/parser/detail/text/config.hpp | 26 ++ .../{ => parser/detail}/text/dangling.hpp | 8 +- .../detail}/text/detail/algorithm.hpp | 10 +- .../detail}/text/detail/iterator.hpp | 6 +- .../detail}/text/detail/sentinel_tag.hpp | 6 +- .../detail}/text/detail/unpack.hpp | 6 +- .../detail}/text/transcode_algorithm.hpp | 172 +-------- .../detail}/text/transcode_iterator.hpp | 351 +++++++++--------- .../detail}/text/transcode_view.hpp | 24 +- .../boost/{ => parser/detail}/text/trie.hpp | 76 ++-- .../{ => parser/detail}/text/trie_fwd.hpp | 4 +- .../boost/{ => parser/detail}/text/utf.hpp | 6 +- include/boost/parser/error_handling.hpp | 4 +- include/boost/parser/error_handling_fwd.hpp | 2 +- include/boost/parser/parser.hpp | 10 +- include/boost/parser/parser_fwd.hpp | 4 +- include/boost/text/config.hpp | 123 ------ 25 files changed, 328 insertions(+), 561 deletions(-) create mode 100644 include/boost/parser/detail/debug_assert.hpp rename include/boost/{ => parser/detail}/text/algorithm.hpp (98%) rename include/boost/{ => parser/detail}/text/concepts.hpp (94%) create mode 100644 include/boost/parser/detail/text/config.hpp rename include/boost/{ => parser/detail}/text/dangling.hpp (67%) rename include/boost/{ => parser/detail}/text/detail/algorithm.hpp (99%) rename include/boost/{ => parser/detail}/text/detail/iterator.hpp (77%) rename include/boost/{ => parser/detail}/text/detail/sentinel_tag.hpp (67%) rename include/boost/{ => parser/detail}/text/detail/unpack.hpp (97%) rename include/boost/{ => parser/detail}/text/transcode_algorithm.hpp (79%) rename include/boost/{ => parser/detail}/text/transcode_iterator.hpp (93%) rename include/boost/{ => parser/detail}/text/transcode_view.hpp (96%) rename include/boost/{ => parser/detail}/text/trie.hpp (96%) rename include/boost/{ => parser/detail}/text/trie_fwd.hpp (90%) rename include/boost/{ => parser/detail}/text/utf.hpp (87%) delete mode 100644 include/boost/text/config.hpp diff --git a/example/json.hpp b/example/json.hpp index 19aa401b..fc0ec3ee 100644 --- a/example/json.hpp +++ b/example/json.hpp @@ -9,8 +9,8 @@ #include "json_fwd.hpp" #include -#include -#include +#include +#include #include #include diff --git a/include/boost/parser/concepts.hpp b/include/boost/parser/concepts.hpp index 532c9d8d..ce9fbbf6 100644 --- a/include/boost/parser/concepts.hpp +++ b/include/boost/parser/concepts.hpp @@ -8,7 +8,7 @@ #include #include -#include +#include // Silence very verbose warnings about std::is_pod being deprecated. TODO: // Remove this if/when Hana accepts releases the fix for this (already on diff --git a/include/boost/parser/config.hpp b/include/boost/parser/config.hpp index 2fa3e67b..3cb3eee3 100644 --- a/include/boost/parser/config.hpp +++ b/include/boost/parser/config.hpp @@ -6,6 +6,8 @@ #ifndef BOOST_PARSER_CONFIG_HPP #define BOOST_PARSER_CONFIG_HPP +#include + // Included for definition of __cpp_lib_concepts. #include diff --git a/include/boost/parser/detail/debug_assert.hpp b/include/boost/parser/detail/debug_assert.hpp new file mode 100644 index 00000000..1e42042c --- /dev/null +++ b/include/boost/parser/detail/debug_assert.hpp @@ -0,0 +1,17 @@ +// Copyright (C) 2020 T. Zachary Laine +// +// 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_PARSER_DETAIL_DEBUG_ASSERT_HPP +#define BOOST_PARSER_DETAIL_DEBUG_ASSERT_HPP + +#if defined(BOOST_PARSER_STANDALONE) +#include +#define BOOST_PARSER_DEBUG_ASSERT(condition) assert(condition) +#else +#include +#define BOOST_PARSER_DEBUG_ASSERT(condition) BOOST_ASSERT(condition) +#endif + +#endif diff --git a/include/boost/parser/detail/numeric.hpp b/include/boost/parser/detail/numeric.hpp index 9dd8750b..c773742e 100644 --- a/include/boost/parser/detail/numeric.hpp +++ b/include/boost/parser/detail/numeric.hpp @@ -450,7 +450,7 @@ namespace boost { namespace parser { namespace detail_spirit_x3 { inline bool extract_sign(Iterator & first, Sentinel last) { (void)last; // silence unused warnings - BOOST_ASSERT(first != last); // precondition + BOOST_PARSER_DEBUG_ASSERT(first != last); // precondition // Extract the sign bool neg = *first == '-'; @@ -705,7 +705,7 @@ namespace boost { namespace parser { namespace detail_spirit_x3 { if (!std::is_same_v) frac_digits = static_cast(std::distance(savef, first)); - BOOST_ASSERT(frac_digits >= 0); + BOOST_PARSER_DEBUG_ASSERT(frac_digits >= 0); } else if (!got_a_number || !p.allow_trailing_dot) { diff --git a/include/boost/parser/detail/printing.hpp b/include/boost/parser/detail/printing.hpp index ff6b026e..4e7ee6a0 100644 --- a/include/boost/parser/detail/printing.hpp +++ b/include/boost/parser/detail/printing.hpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include diff --git a/include/boost/text/algorithm.hpp b/include/boost/parser/detail/text/algorithm.hpp similarity index 98% rename from include/boost/text/algorithm.hpp rename to include/boost/parser/detail/text/algorithm.hpp index 63576a12..cd59d6ce 100644 --- a/include/boost/text/algorithm.hpp +++ b/include/boost/parser/detail/text/algorithm.hpp @@ -3,10 +3,10 @@ // 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_TEXT_ALGORITHM_HPP -#define BOOST_TEXT_ALGORITHM_HPP +#ifndef BOOST_PARSER_DETAIL_TEXT_ALGORITHM_HPP +#define BOOST_PARSER_DETAIL_TEXT_ALGORITHM_HPP -#include +#include #include @@ -403,7 +403,7 @@ namespace boost { namespace text { }} -#if BOOST_TEXT_USE_CONCEPTS +#if BOOST_PARSER_USE_CONCEPTS namespace std::ranges { template diff --git a/include/boost/text/concepts.hpp b/include/boost/parser/detail/text/concepts.hpp similarity index 94% rename from include/boost/text/concepts.hpp rename to include/boost/parser/detail/text/concepts.hpp index 2632d6f9..666f7603 100644 --- a/include/boost/text/concepts.hpp +++ b/include/boost/parser/detail/text/concepts.hpp @@ -3,18 +3,18 @@ // 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_TEXT_CONCEPTS_HPP -#define BOOST_TEXT_CONCEPTS_HPP +#ifndef BOOST_PARSER_DETAIL_TEXT_CONCEPTS_HPP +#define BOOST_PARSER_DETAIL_TEXT_CONCEPTS_HPP -#include -#include +#include +#include -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS #include -namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V2 { +namespace boost { namespace text { BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V2 { template concept code_unit = std::integral && sizeof(T) == (int)F; diff --git a/include/boost/parser/detail/text/config.hpp b/include/boost/parser/detail/text/config.hpp new file mode 100644 index 00000000..fb1e9867 --- /dev/null +++ b/include/boost/parser/detail/text/config.hpp @@ -0,0 +1,26 @@ +// Copyright (C) 2020 T. Zachary Laine +// +// 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_PARSER_DETAIL_TEXT_CONFIG_HPP +#define BOOST_PARSER_DETAIL_TEXT_CONFIG_HPP + +// Included for definition of __cpp_lib_concepts. +#include + + +// The inline namespaces v1 and v2 represent pre- and post-C++20. v1 is +// inline for standards before C++20, and v2 is inline for C++20 and later. +// Note that this only applies to code for which a v2 namespace alternative +// exists. Some instances of the v1 namespace may still be inline, if there +// is no v2 version of its contents. +#if BOOST_PARSER_USE_CONCEPTS +# define BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V1 namespace v1 +# define BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V2 inline namespace v2 +#else +# define BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V1 inline namespace v1 +# define BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V2 namespace v2 +#endif + +#endif diff --git a/include/boost/text/dangling.hpp b/include/boost/parser/detail/text/dangling.hpp similarity index 67% rename from include/boost/text/dangling.hpp rename to include/boost/parser/detail/text/dangling.hpp index 02404b74..5c14687c 100644 --- a/include/boost/text/dangling.hpp +++ b/include/boost/parser/detail/text/dangling.hpp @@ -3,13 +3,13 @@ // 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_TEXT_DANGLING_HPP -#define BOOST_TEXT_DANGLING_HPP +#ifndef BOOST_PARSER_DETAIL_TEXT_DANGLING_HPP +#define BOOST_PARSER_DETAIL_TEXT_DANGLING_HPP -#include +#include -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS namespace boost::text { template diff --git a/include/boost/text/detail/algorithm.hpp b/include/boost/parser/detail/text/detail/algorithm.hpp similarity index 99% rename from include/boost/text/detail/algorithm.hpp rename to include/boost/parser/detail/text/detail/algorithm.hpp index 3536ceb4..555d6a9c 100644 --- a/include/boost/text/detail/algorithm.hpp +++ b/include/boost/parser/detail/text/detail/algorithm.hpp @@ -3,12 +3,10 @@ // 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_TEXT_DETAIL_ALGORITHM_HPP -#define BOOST_TEXT_DETAIL_ALGORITHM_HPP +#ifndef BOOST_PARSER_DETAIL_TEXT_DETAIL_ALGORITHM_HPP +#define BOOST_PARSER_DETAIL_TEXT_DETAIL_ALGORITHM_HPP -#include - -#include +#include #include #include @@ -23,7 +21,7 @@ namespace boost { namespace text { namespace detail { using remove_cv_ref_t = typename std::remove_cv::type>::type; -#if BOOST_TEXT_USE_CONCEPTS +#if BOOST_PARSER_USE_CONCEPTS template using iterator_t = std::ranges::iterator_t; diff --git a/include/boost/text/detail/iterator.hpp b/include/boost/parser/detail/text/detail/iterator.hpp similarity index 77% rename from include/boost/text/detail/iterator.hpp rename to include/boost/parser/detail/text/detail/iterator.hpp index ffce698f..fe79f79d 100644 --- a/include/boost/text/detail/iterator.hpp +++ b/include/boost/parser/detail/text/detail/iterator.hpp @@ -3,10 +3,10 @@ // 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_TEXT_DETAIL_ITERATOR_HPP -#define BOOST_TEXT_DETAIL_ITERATOR_HPP +#ifndef BOOST_PARSER_DETAIL_TEXT_DETAIL_ITERATOR_HPP +#define BOOST_PARSER_DETAIL_TEXT_DETAIL_ITERATOR_HPP -#include +#include #include #include diff --git a/include/boost/text/detail/sentinel_tag.hpp b/include/boost/parser/detail/text/detail/sentinel_tag.hpp similarity index 67% rename from include/boost/text/detail/sentinel_tag.hpp rename to include/boost/parser/detail/text/detail/sentinel_tag.hpp index c4515e54..1b85415e 100644 --- a/include/boost/text/detail/sentinel_tag.hpp +++ b/include/boost/parser/detail/text/detail/sentinel_tag.hpp @@ -3,10 +3,10 @@ // 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_TEXT_DETAIL_SENTINEL_TAG_HPP -#define BOOST_TEXT_DETAIL_SENTINEL_TAG_HPP +#ifndef BOOST_PARSER_DETAIL_TEXT_DETAIL_SENTINEL_TAG_HPP +#define BOOST_PARSER_DETAIL_TEXT_DETAIL_SENTINEL_TAG_HPP -#include +#include namespace boost { namespace text { namespace detail { diff --git a/include/boost/text/detail/unpack.hpp b/include/boost/parser/detail/text/detail/unpack.hpp similarity index 97% rename from include/boost/text/detail/unpack.hpp rename to include/boost/parser/detail/text/detail/unpack.hpp index 54acba07..e173a74b 100644 --- a/include/boost/text/detail/unpack.hpp +++ b/include/boost/parser/detail/text/detail/unpack.hpp @@ -3,10 +3,10 @@ // 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_TEXT_DETAIL_UNPACK_HPP -#define BOOST_TEXT_DETAIL_UNPACK_HPP +#ifndef BOOST_PARSER_DETAIL_TEXT_DETAIL_UNPACK_HPP +#define BOOST_PARSER_DETAIL_TEXT_DETAIL_UNPACK_HPP -#include +#include namespace boost { namespace text { namespace detail { diff --git a/include/boost/text/transcode_algorithm.hpp b/include/boost/parser/detail/text/transcode_algorithm.hpp similarity index 79% rename from include/boost/text/transcode_algorithm.hpp rename to include/boost/parser/detail/text/transcode_algorithm.hpp index fa487fbb..01820a21 100644 --- a/include/boost/text/transcode_algorithm.hpp +++ b/include/boost/parser/detail/text/transcode_algorithm.hpp @@ -4,29 +4,13 @@ // 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_TEXT_TRANSCODE_ALGORITHM_HPP -#define BOOST_TEXT_TRANSCODE_ALGORITHM_HPP +#ifndef BOOST_PARSER_DETAIL_TEXT_TRANSCODE_ALGORITHM_HPP +#define BOOST_PARSER_DETAIL_TEXT_TRANSCODE_ALGORITHM_HPP -#include -#include +#include +#include #include -#include - - -#if !defined(BOOST_TEXT_USE_SIMD) || BOOST_TEXT_USE_SIMD == 1 -#if BOOST_HW_SIMD_X86_SSE2_VERSION <= BOOST_HW_SIMD_X86 -#if defined(BOOST_GCC) || defined(BOOST_CLANG) -#include -#define BOOST_TEXT_USE_SIMD 1 -#elif defined(BOOST_MSVC) -#include -#define BOOST_TEXT_USE_SIMD 1 -#else -#define BOOST_TEXT_USE_SIMD 0 -#endif -#endif -#endif namespace boost { namespace text { @@ -42,7 +26,7 @@ namespace boost { namespace text { namespace detail { template - BOOST_TEXT_CXX14_CONSTEXPR OutIter + constexpr OutIter read_into_utf8_iter(uint32_t cp, OutIter out) { if (cp < 0x80) { @@ -74,7 +58,7 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR OutIter + constexpr OutIter read_into_utf16_iter(uint32_t cp, OutIter out) { uint16_t const high_surrogate_base = 0xd7c0; @@ -92,85 +76,6 @@ namespace boost { namespace text { return out; } -#if BOOST_TEXT_USE_SIMD - template - __m128i load_chars_for_sse(Iter it) noexcept - { - std::array chars; - std::copy(it, it + 16, chars.begin()); - return _mm_loadu_si128((__m128i const *)chars.data()); - } - - inline __m128i load_chars_for_sse(char const * it) noexcept - { - return _mm_loadu_si128((__m128i const *)it); - } - -#if defined(BOOST_GCC) || defined(BOOST_CLANG) - inline int trailing_zeros(uint32_t x) noexcept - { - return __builtin_ctz(x); - } -#elif defined(BOOST_MSVC) - inline int trailing_zeros(uint32_t x) noexcept - { - unsigned long retval; - _BitScanForward(&retval, (unsigned long)x); - return (int)retval; - } -#else - // Table taken from - // https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightMultLookup - inline int trailing_zeros(uint32_t x) noexcept - { - constexpr int debruijn_bit_position[32] = { - 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, - 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9, - }; - return debruijn_bit_position - [((uint32_t)((x & -x) * 0x077CB531U)) >> 27]; - } -#endif - - // TODO: Overload based on contiguous iterators in C++20 and later. - template - int32_t * sse_out_ptr(OutIter out, std::array & tmp) - { - return tmp.data(); - } - - inline int32_t * - sse_out_ptr(int32_t * out, std::array & tmp) - { - return out; - } - - inline int32_t * - sse_out_ptr(uint32_t * out, std::array & tmp) - { - return (int32_t *)out; - } - - template - void finalize_sse_out( - OutIter & out, std::array const & tmp, int incr) - { - out = std::copy(tmp.begin(), tmp.begin() + incr, out); - } - - inline void finalize_sse_out( - int32_t *& out, std::array const & tmp, int incr) - { - out += incr; - } - - inline void finalize_sse_out( - uint32_t *& out, std::array const & tmp, int incr) - { - out += incr; - } -#endif - template< bool UseN, typename InputIter, @@ -205,31 +110,6 @@ namespace boost { namespace text { OutIter out, std::random_access_iterator_tag) { -#if BOOST_TEXT_USE_SIMD - while ((int)sizeof(__m128i) <= last - first && - (!UseN || (int)sizeof(__m128i) <= n)) { - if ((unsigned char)*first < 0x80) { - __m128i chunk = load_chars_for_sse(first); - int32_t mask = _mm_movemask_epi8(chunk); - __m128i half = _mm_unpacklo_epi8(chunk, _mm_set1_epi8(0)); - std::array temp; - int32_t * out_ptr = sse_out_ptr(out, temp); - _mm_storeu_si128((__m128i *)out_ptr, half); - half = _mm_unpackhi_epi8(chunk, _mm_set1_epi8(0)); - _mm_storeu_si128((__m128i *)(out_ptr + 8), half); - - int const incr = mask == 0 ? 16 : trailing_zeros(mask); - first += incr; - n -= incr; - finalize_sse_out(out, temp, incr); - } else { - auto const cp = detail::advance(first, last); - out = detail::read_into_utf16_iter(cp, out); - --n; - } - } -#endif - return transcode_utf_8_to_16( first, last, n, out, std::input_iterator_tag{}); } @@ -268,40 +148,6 @@ namespace boost { namespace text { OutIter out, std::random_access_iterator_tag) { -#if BOOST_TEXT_USE_SIMD - while ((int)sizeof(__m128i) <= last - first && - (!UseN || (int)sizeof(__m128i) <= n)) { - if ((unsigned char)*first < 0x80) { - __m128i zero = _mm_set1_epi8(0); - __m128i chunk = load_chars_for_sse(first); - int32_t const mask = _mm_movemask_epi8(chunk); - - __m128i half = _mm_unpacklo_epi8(chunk, zero); - __m128i qrtr = _mm_unpacklo_epi16(half, zero); - std::array temp; - int32_t * out_ptr = sse_out_ptr(out, temp); - _mm_storeu_si128((__m128i *)out_ptr, qrtr); - qrtr = _mm_unpackhi_epi16(half, zero); - _mm_storeu_si128((__m128i *)(out_ptr + 4), qrtr); - - half = _mm_unpackhi_epi8(chunk, zero); - qrtr = _mm_unpacklo_epi16(half, zero); - _mm_storeu_si128((__m128i *)(out_ptr + 8), qrtr); - qrtr = _mm_unpackhi_epi16(half, zero); - _mm_storeu_si128((__m128i *)(out_ptr + 12), qrtr); - - int const incr = mask == 0 ? 16 : trailing_zeros(mask); - first += incr; - n -= incr; - finalize_sse_out(out, temp, incr); - } else { - *out = detail::advance(first, last); - ++out; - --n; - } - } -#endif - return transcode_utf_8_to_32( first, last, n, out, std::input_iterator_tag{}); } @@ -494,7 +340,7 @@ namespace boost { namespace text { }} -namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V1 { +namespace boost { namespace text { BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V1 { namespace dtl { template< @@ -674,9 +520,9 @@ namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V1 { }}} -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS -namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V2 { +namespace boost { namespace text { BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V2 { /** Copies the code points in the range `[first, last)` to `out`, changing the encoding to UTF-8. */ diff --git a/include/boost/text/transcode_iterator.hpp b/include/boost/parser/detail/text/transcode_iterator.hpp similarity index 93% rename from include/boost/text/transcode_iterator.hpp rename to include/boost/parser/detail/text/transcode_iterator.hpp index 25b0f87d..f58735bb 100644 --- a/include/boost/text/transcode_iterator.hpp +++ b/include/boost/parser/detail/text/transcode_iterator.hpp @@ -3,15 +3,16 @@ // 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_TEXT_TRANSCODE_ITERATOR_HPP -#define BOOST_TEXT_TRANSCODE_ITERATOR_HPP +#ifndef BOOST_PARSER_DETAIL_TEXT_TRANSCODE_ITERATOR_HPP +#define BOOST_PARSER_DETAIL_TEXT_TRANSCODE_ITERATOR_HPP -#include -#include -#include -#include +#include + +#include +#include +#include +#include -#include #include #include @@ -42,7 +43,7 @@ namespace boost { namespace text { {}; template - inline BOOST_TEXT_CXX14_CONSTEXPR OutIter + inline constexpr OutIter read_into_buf(uint32_t cp, OutIter buf) { if (cp < 0x80) { @@ -74,14 +75,14 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR OutIter + constexpr OutIter write_cp_utf8(uint32_t cp, OutIter out) { return detail::read_into_buf(cp, out); } template - BOOST_TEXT_CXX14_CONSTEXPR OutIter + constexpr OutIter write_cp_utf16(uint32_t cp, OutIter out) { if (cp < 0x10000) { @@ -123,19 +124,19 @@ namespace boost { namespace text { constexpr uint32_t replacement_character() noexcept { return 0xfffd; } /** Returns true iff `c` is a Unicode surrogate. */ - inline BOOST_TEXT_CXX14_CONSTEXPR bool surrogate(uint32_t c) noexcept + inline constexpr bool surrogate(uint32_t c) noexcept { return high_surrogate_min <= c && c <= low_surrogate_max; } /** Returns true iff `c` is a Unicode high surrogate. */ - inline BOOST_TEXT_CXX14_CONSTEXPR bool high_surrogate(uint32_t c) noexcept + inline constexpr bool high_surrogate(uint32_t c) noexcept { return high_surrogate_min <= c && c <= high_surrogate_max; } /** Returns true iff `c` is a Unicode low surrogate. */ - inline BOOST_TEXT_CXX14_CONSTEXPR bool low_surrogate(uint32_t c) noexcept + inline constexpr bool low_surrogate(uint32_t c) noexcept { return low_surrogate_min <= c && c <= low_surrogate_max; } @@ -143,7 +144,7 @@ namespace boost { namespace text { /** Returns true iff `c` is a Unicode reserved noncharacter. \see Unicode 3.4/D14 */ - inline BOOST_TEXT_CXX14_CONSTEXPR bool + inline constexpr bool reserved_noncharacter(uint32_t c) noexcept { bool const byte01_reserved = (c & 0xffff) >= 0xfffe; @@ -155,7 +156,7 @@ namespace boost { namespace text { /** Returns true iff `c` is a valid Unicode code point. \see Unicode 3.9/D90 */ - inline BOOST_TEXT_CXX14_CONSTEXPR bool valid_code_point(uint32_t c) noexcept + inline constexpr bool valid_code_point(uint32_t c) noexcept { return c <= 0x10ffff && !surrogate(c) && !reserved_noncharacter(c); } @@ -177,7 +178,7 @@ namespace boost { namespace text { point, returns the number of bytes occupied by that code point (in the range `[1, 4]`). Returns a value < 0 if `first_unit` is not a valid initial UTF-8 code unit. */ - inline BOOST_TEXT_CXX14_CONSTEXPR int + inline constexpr int utf8_code_units(unsigned char first_unit) noexcept { return first_unit <= 0x7f @@ -191,7 +192,7 @@ namespace boost { namespace text { point, returns the number of code units occupied by that code point (in the range `[1, 2]`). Returns a negative value if `first_unit` is not a valid initial UTF-16 code unit. */ - inline BOOST_TEXT_CXX14_CONSTEXPR int + inline constexpr int utf16_code_units(uint16_t first_unit) noexcept { if (boost::text::low_surrogate(first_unit)) @@ -209,28 +210,28 @@ namespace boost { namespace text { constexpr optional_iter() : it_(), valid_(false) {} constexpr optional_iter(Iter it) : it_(it), valid_(true) {} - BOOST_TEXT_CXX14_CONSTEXPR operator bool() const noexcept + constexpr operator bool() const noexcept { return valid_; } - BOOST_TEXT_CXX14_CONSTEXPR Iter operator*() const noexcept + constexpr Iter operator*() const noexcept { - BOOST_ASSERT(valid_); + BOOST_PARSER_DEBUG_ASSERT(valid_); return it_; } Iter & operator*() noexcept { - BOOST_ASSERT(valid_); + BOOST_PARSER_DEBUG_ASSERT(valid_); return it_; } - friend BOOST_TEXT_CXX14_CONSTEXPR bool + friend constexpr bool operator==(optional_iter lhs, optional_iter rhs) noexcept { return lhs.valid_ == rhs.valid_ && (!lhs.valid_ || lhs.it_ == rhs.it_); } - friend BOOST_TEXT_CXX14_CONSTEXPR bool + friend constexpr bool operator!=(optional_iter lhs, optional_iter rhs) noexcept { return !(lhs == rhs); @@ -243,10 +244,10 @@ namespace boost { namespace text { // Follow Table 3-7 in Unicode 3.9/D92 template - BOOST_TEXT_CXX14_CONSTEXPR optional_iter + constexpr optional_iter end_of_invalid_utf8(Iter it) noexcept { - BOOST_ASSERT(!boost::text::continuation(*it)); + BOOST_PARSER_DEBUG_ASSERT(!boost::text::continuation(*it)); if (detail::in(0, *it, 0x7f)) return optional_iter{}; @@ -326,7 +327,7 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR Iter decrement(Iter it) noexcept + constexpr Iter decrement(Iter it) noexcept { Iter retval = it; @@ -360,7 +361,7 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR Iter decrement(Iter first, Iter it) noexcept + constexpr Iter decrement(Iter first, Iter it) noexcept { Iter retval = it; @@ -561,7 +562,7 @@ namespace boost { namespace text { { using value_type = void; using difference_type = -#if BOOST_TEXT_USE_CONCEPTS +#if BOOST_PARSER_USE_CONCEPTS std::ptrdiff_t; #else void; @@ -595,12 +596,12 @@ namespace boost { namespace text { }} -namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V1 { +namespace boost { namespace text { BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V1 { /** Returns the first code unit in `[first, last)` that is not properly UTF-8 encoded, or `last` if no such code unit is found. */ template - BOOST_TEXT_CXX14_CONSTEXPR detail::enable_utf8_cp_t + constexpr detail::enable_utf8_cp_t find_invalid_encoding(Iter first, Iter last) noexcept { while (first != last) { @@ -620,7 +621,7 @@ namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V1 { /** Returns the first code unit in `[first, last)` that is not properly UTF-16 encoded, or `last` if no such code unit is found. */ template - BOOST_TEXT_CXX14_CONSTEXPR detail::enable_utf16_cp_t + constexpr detail::enable_utf16_cp_t find_invalid_encoding(Iter first, Iter last) noexcept { while (first != last) { @@ -639,7 +640,7 @@ namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V1 { /** Returns true iff `[first, last)` is properly UTF-8 encoded. */ template - BOOST_TEXT_CXX14_CONSTEXPR detail::enable_utf8_cp_t encoded( + constexpr detail::enable_utf8_cp_t encoded( Iter first, Iter last) noexcept { return v1::find_invalid_encoding(first, last) == last; @@ -647,7 +648,7 @@ namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V1 { /** Returns true iff `[first, last)` is properly UTF-16 encoded. */ template - BOOST_TEXT_CXX14_CONSTEXPR detail::enable_utf16_cp_t encoded( + constexpr detail::enable_utf16_cp_t encoded( Iter first, Iter last) noexcept { return v1::find_invalid_encoding(first, last) == last; @@ -656,7 +657,7 @@ namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V1 { /** Returns true iff `[first, last)` is empty or the initial UTF-8 code units in `[first, last)` form a valid Unicode code point. */ template - BOOST_TEXT_CXX14_CONSTEXPR detail::enable_utf8_cp_t + constexpr detail::enable_utf8_cp_t starts_encoded(Iter first, Iter last) noexcept { if (first == last) @@ -672,7 +673,7 @@ namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V1 { /** Returns true iff `[first, last)` is empty or the initial UTF-16 code units in `[first, last)` form a valid Unicode code point. */ template - BOOST_TEXT_CXX14_CONSTEXPR detail::enable_utf16_cp_t + constexpr detail::enable_utf16_cp_t starts_encoded(Iter first, Iter last) noexcept { if (first == last) @@ -688,7 +689,7 @@ namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V1 { /** Returns true iff `[first, last)` is empty or the final UTF-8 code units in `[first, last)` form a valid Unicode code point. */ template - BOOST_TEXT_CXX14_CONSTEXPR detail::enable_utf8_cp_t + constexpr detail::enable_utf8_cp_t ends_encoded(Iter first, Iter last) noexcept { if (first == last) @@ -704,7 +705,7 @@ namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V1 { /** Returns true iff `[first, last)` is empty or the final UTF-16 code units in `[first, last)` form a valid Unicode code point. */ template - BOOST_TEXT_CXX14_CONSTEXPR detail::enable_utf16_cp_t + constexpr detail::enable_utf16_cp_t ends_encoded(Iter first, Iter last) noexcept { if (first == last) @@ -719,9 +720,9 @@ namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V1 { }}} -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS -namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V2 { +namespace boost { namespace text { BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V2 { /** Returns the first code unit in `[first, last)` that is not properly UTF-8 encoded, or `last` if no such code unit is found. */ @@ -909,7 +910,7 @@ namespace boost { namespace text { #else -#if BOOST_TEXT_USE_CONCEPTS +#if BOOST_PARSER_USE_CONCEPTS template // clang-format off @@ -965,25 +966,25 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator==(T * p, null_sentinel) + constexpr auto operator==(T * p, null_sentinel) ->decltype(detail::null_sent_eq_dispatch::call(p)) { return detail::null_sent_eq_dispatch::call(p); } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator!=(T * p, null_sentinel) + constexpr auto operator!=(T * p, null_sentinel) ->decltype(detail::null_sent_eq_dispatch::call(p)) { return !detail::null_sent_eq_dispatch::call(p); } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator==(null_sentinel, T * p) + constexpr auto operator==(null_sentinel, T * p) ->decltype(detail::null_sent_eq_dispatch::call(p)) { return detail::null_sent_eq_dispatch::call(p); } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator!=(null_sentinel, T * p) + constexpr auto operator!=(null_sentinel, T * p) ->decltype(detail::null_sent_eq_dispatch::call(p)) { return !detail::null_sent_eq_dispatch::call(p); @@ -995,7 +996,7 @@ namespace boost { namespace text { /** A UTF-8 to UTF-16 converting iterator. */ -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template< utf8_iter I, std::sentinel_for S = I, @@ -1010,7 +1011,7 @@ namespace boost { namespace text { /** A UTF-32 to UTF-8 converting iterator. */ -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template< utf32_iter I, std::sentinel_for S = I, @@ -1027,7 +1028,7 @@ namespace boost { namespace text { static bool const throw_on_error = !noexcept(std::declval()(0)); -#if !BOOST_TEXT_USE_CONCEPTS +#if !BOOST_PARSER_USE_CONCEPTS static_assert( std::is_same< typename std::iterator_traits::iterator_category, @@ -1046,14 +1047,14 @@ namespace boost { namespace text { constexpr utf_32_to_8_iterator() noexcept : first_(), it_(), last_(), index_(4), buf_() {} - explicit BOOST_TEXT_CXX14_CONSTEXPR + explicit constexpr utf_32_to_8_iterator(I first, I it, S last) noexcept : first_(first), it_(it), last_(last), index_(0), buf_() { if (it_ != last_) read_into_buf(); } -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template // clang-format off requires std::convertible_to && std::convertible_to @@ -1075,20 +1076,20 @@ namespace boost { namespace text { buf_(other.buf_) {} - BOOST_TEXT_CXX14_CONSTEXPR char operator*() const + constexpr char operator*() const noexcept(!throw_on_error) { return buf_[index_]; } - BOOST_TEXT_CXX14_CONSTEXPR I base() const noexcept { return it_; } + constexpr I base() const noexcept { return it_; } - BOOST_TEXT_CXX14_CONSTEXPR utf_32_to_8_iterator & + constexpr utf_32_to_8_iterator & operator++() noexcept(!throw_on_error) { ++index_; if (at_buf_end()) { - BOOST_ASSERT(it_ != last_); + BOOST_PARSER_DEBUG_ASSERT(it_ != last_); ++it_; index_ = 0; if (it_ != last_) @@ -1097,13 +1098,13 @@ namespace boost { namespace text { return *this; } - BOOST_TEXT_CXX14_CONSTEXPR utf_32_to_8_iterator & + constexpr utf_32_to_8_iterator & operator--() noexcept(!throw_on_error) { if (0 < index_) { --index_; } else { - BOOST_ASSERT(it_ != first_); + BOOST_PARSER_DEBUG_ASSERT(it_ != first_); --it_; auto out = read_into_buf(); index_ = out - buf_.data() - 1; @@ -1117,7 +1118,7 @@ namespace boost { namespace text { typename I2, typename S2, typename ErrorHandler2> - friend BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + friend constexpr auto operator==( utf_32_to_8_iterator const & lhs, utf_32_to_8_iterator const & rhs) noexcept -> decltype(lhs.base() == rhs.base()); @@ -1142,7 +1143,7 @@ namespace boost { namespace text { return buf_[index_] == '\0'; } - BOOST_TEXT_CXX14_CONSTEXPR char * + constexpr char * read_into_buf() noexcept(!throw_on_error) { uint32_t cp = static_cast(*it_); @@ -1158,7 +1159,7 @@ namespace boost { namespace text { int index_; std::array buf_; -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template< utf32_iter I2, std::sentinel_for S2, @@ -1172,7 +1173,7 @@ namespace boost { namespace text { }; template - BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + constexpr auto operator==( utf_32_to_8_iterator const & lhs, Sentinel rhs) noexcept -> decltype(lhs.base() == rhs) { @@ -1180,7 +1181,7 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + constexpr auto operator==( Sentinel lhs, utf_32_to_8_iterator const & rhs) noexcept -> decltype(rhs.base() == lhs) @@ -1189,7 +1190,7 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator!=( + constexpr auto operator!=( utf_32_to_8_iterator const & lhs, Sentinel rhs) noexcept -> decltype(lhs.base() != rhs) { @@ -1197,7 +1198,7 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator!=( + constexpr auto operator!=( Sentinel lhs, utf_32_to_8_iterator const & rhs) noexcept -> decltype(rhs.base() != lhs) @@ -1211,7 +1212,7 @@ namespace boost { namespace text { typename Iter2, typename Sentinel2, typename ErrorHandler> - BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + constexpr auto operator==( utf_32_to_8_iterator const & lhs, utf_32_to_8_iterator const & rhs) noexcept -> decltype(lhs.base() == rhs.base()) @@ -1225,7 +1226,7 @@ namespace boost { namespace text { typename Iter2, typename Sentinel2, typename ErrorHandler> - BOOST_TEXT_CXX14_CONSTEXPR auto operator!=( + constexpr auto operator!=( utf_32_to_8_iterator const & lhs, utf_32_to_8_iterator const & rhs) noexcept -> decltype(!(lhs == rhs)) @@ -1235,7 +1236,7 @@ namespace boost { namespace text { /** An out iterator that converts UTF-32 to UTF-8. */ -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template Iter> #else template @@ -1334,7 +1335,7 @@ namespace boost { namespace text { /** A UTF-8 to UTF-32 converting iterator. */ -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template< utf8_iter I, std::sentinel_for S = I, @@ -1356,7 +1357,7 @@ namespace boost { namespace text { : first_(first), it_(it), last_(last) {} -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template // clang-format off requires std::convertible_to && std::convertible_to @@ -1376,30 +1377,30 @@ namespace boost { namespace text { last_(other.last_) {} - BOOST_TEXT_CXX14_CONSTEXPR uint32_t operator*() const + constexpr uint32_t operator*() const noexcept(!throw_on_error) { - BOOST_ASSERT(!at_end(it_)); + BOOST_PARSER_DEBUG_ASSERT(!at_end(it_)); unsigned char curr_c = *it_; if (curr_c < 0x80) return curr_c; return get_value().value_; } - BOOST_TEXT_CXX14_CONSTEXPR I base() const noexcept { return it_; } + constexpr I base() const noexcept { return it_; } - BOOST_TEXT_CXX14_CONSTEXPR utf_8_to_32_iterator & + constexpr utf_8_to_32_iterator & operator++() noexcept(!throw_on_error) { - BOOST_ASSERT(it_ != last_); + BOOST_PARSER_DEBUG_ASSERT(it_ != last_); it_ = increment(); return *this; } - BOOST_TEXT_CXX14_CONSTEXPR utf_8_to_32_iterator & + constexpr utf_8_to_32_iterator & operator--() noexcept(!throw_on_error) { - BOOST_ASSERT(it_ != first_); + BOOST_PARSER_DEBUG_ASSERT(it_ != first_); it_ = detail::decrement(first_, it_); return *this; } @@ -1423,7 +1424,7 @@ namespace boost { namespace text { I it_; }; - BOOST_TEXT_CXX14_CONSTEXPR bool check_continuation( + constexpr bool check_continuation( unsigned char c, unsigned char lo = 0x80, unsigned char hi = 0xbf) const noexcept(!throw_on_error) @@ -1438,7 +1439,7 @@ namespace boost { namespace text { } } - BOOST_TEXT_CXX14_CONSTEXPR bool at_end(I it) const + constexpr bool at_end(I it) const noexcept(!throw_on_error) { if (it == last_) { @@ -1451,7 +1452,7 @@ namespace boost { namespace text { } } - BOOST_TEXT_CXX14_CONSTEXPR get_value_result get_value() const + constexpr get_value_result get_value() const noexcept(!throw_on_error) { // It turns out that this naive implementation is faster than the @@ -1645,7 +1646,7 @@ namespace boost { namespace text { #endif } - BOOST_TEXT_CXX14_CONSTEXPR I increment() const noexcept(!throw_on_error) + constexpr I increment() const noexcept(!throw_on_error) { unsigned char curr_c = *it_; if (curr_c < 0x80) @@ -1657,7 +1658,7 @@ namespace boost { namespace text { I it_; S last_; -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template< utf8_iter I2, std::sentinel_for S2, @@ -1667,7 +1668,7 @@ namespace boost { namespace text { #endif friend struct utf_8_to_16_iterator; -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template< utf8_iter I2, std::sentinel_for S2, @@ -1681,7 +1682,7 @@ namespace boost { namespace text { }; template - BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + constexpr auto operator==( utf_8_to_32_iterator const & lhs, Sentinel rhs) noexcept -> decltype(lhs.base() == rhs) { @@ -1689,7 +1690,7 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + constexpr auto operator==( Sentinel lhs, utf_8_to_32_iterator const & rhs) noexcept -> decltype(rhs.base() == lhs) @@ -1698,7 +1699,7 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator!=( + constexpr auto operator!=( utf_8_to_32_iterator const & lhs, Sentinel rhs) noexcept -> decltype(lhs.base() != rhs) { @@ -1706,7 +1707,7 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator!=( + constexpr auto operator!=( Sentinel lhs, utf_8_to_32_iterator const & rhs) noexcept -> decltype(rhs.base() != lhs) @@ -1720,7 +1721,7 @@ namespace boost { namespace text { typename Iter2, typename Sentinel2, typename ErrorHandler> - BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + constexpr auto operator==( utf_8_to_32_iterator const & lhs, utf_8_to_32_iterator const & rhs) noexcept -> decltype(lhs.base() == rhs.base()) @@ -1734,7 +1735,7 @@ namespace boost { namespace text { typename Iter2, typename Sentinel2, typename ErrorHandler> - BOOST_TEXT_CXX14_CONSTEXPR auto operator!=( + constexpr auto operator!=( utf_8_to_32_iterator const & lhs, utf_8_to_32_iterator const & rhs) noexcept -> decltype(!(lhs == rhs)) @@ -1779,7 +1780,7 @@ namespace boost { namespace text { } /** An out iterator that converts UTF-8 to UTF-32. */ -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template Iter> #else template @@ -1906,7 +1907,7 @@ namespace boost { namespace text { /** A UTF-32 to UTF-16 converting iterator. */ -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template< utf32_iter I, std::sentinel_for S = I, @@ -1924,7 +1925,7 @@ namespace boost { namespace text { static bool const throw_on_error = !noexcept(std::declval()(0)); -#if !BOOST_TEXT_USE_CONCEPTS +#if !BOOST_PARSER_USE_CONCEPTS static_assert( std::is_same< typename std::iterator_traits::iterator_category, @@ -1944,14 +1945,14 @@ namespace boost { namespace text { constexpr utf_32_to_16_iterator() noexcept : first_(), it_(), last_(), index_(2), buf_() {} - explicit BOOST_TEXT_CXX14_CONSTEXPR + explicit constexpr utf_32_to_16_iterator(I first, I it, S last) noexcept : first_(first), it_(it), last_(last), index_(0), buf_() { if (it_ != last_) read_into_buf(); } -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template // clang-format off requires std::convertible_to && std::convertible_to @@ -1974,20 +1975,20 @@ namespace boost { namespace text { buf_(other.buf_) {} - BOOST_TEXT_CXX14_CONSTEXPR uint16_t operator*() const + constexpr uint16_t operator*() const noexcept(!throw_on_error) { return buf_[index_]; } - BOOST_TEXT_CXX14_CONSTEXPR I base() const noexcept { return it_; } + constexpr I base() const noexcept { return it_; } - BOOST_TEXT_CXX14_CONSTEXPR utf_32_to_16_iterator & + constexpr utf_32_to_16_iterator & operator++() noexcept(!throw_on_error) { ++index_; if (at_buf_end()) { - BOOST_ASSERT(it_ != last_); + BOOST_PARSER_DEBUG_ASSERT(it_ != last_); ++it_; index_ = 0; if (it_ != last_) @@ -1996,13 +1997,13 @@ namespace boost { namespace text { return *this; } - BOOST_TEXT_CXX14_CONSTEXPR utf_32_to_16_iterator & + constexpr utf_32_to_16_iterator & operator--() noexcept(!throw_on_error) { if (0 < index_) { --index_; } else { - BOOST_ASSERT(it_ != first_); + BOOST_PARSER_DEBUG_ASSERT(it_ != first_); --it_; auto out = read_into_buf(); index_ = out - buf_.data() - 1; @@ -2016,7 +2017,7 @@ namespace boost { namespace text { typename I2, typename S2, typename ErrorHandler2> - friend BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + friend constexpr auto operator==( utf_32_to_16_iterator const & lhs, utf_32_to_16_iterator const & rhs) noexcept -> decltype(lhs.base() == rhs.base()); @@ -2036,7 +2037,7 @@ namespace boost { namespace text { private: constexpr bool at_buf_end() const noexcept { return buf_[index_] == 0; } - BOOST_TEXT_CXX14_CONSTEXPR uint16_t * + constexpr uint16_t * read_into_buf() noexcept(!throw_on_error) { auto const last = detail::write_cp_utf16(*it_, buf_.data()); @@ -2050,7 +2051,7 @@ namespace boost { namespace text { int index_; std::array buf_; -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template< utf32_iter I2, std::sentinel_for S2, @@ -2063,7 +2064,7 @@ namespace boost { namespace text { }; template - BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + constexpr auto operator==( utf_32_to_16_iterator const & lhs, Sentinel rhs) noexcept -> decltype(lhs.base() == rhs) { @@ -2071,7 +2072,7 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + constexpr auto operator==( Sentinel lhs, utf_32_to_16_iterator const & rhs) noexcept -> decltype(rhs.base() == lhs) @@ -2080,7 +2081,7 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator!=( + constexpr auto operator!=( utf_32_to_16_iterator const & lhs, Sentinel rhs) noexcept -> decltype(lhs.base() != rhs) { @@ -2088,7 +2089,7 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator!=( + constexpr auto operator!=( Sentinel lhs, utf_32_to_16_iterator const & rhs) noexcept -> decltype(rhs.base() != lhs) @@ -2102,7 +2103,7 @@ namespace boost { namespace text { typename Iter2, typename Sentinel2, typename ErrorHandler> - BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + constexpr auto operator==( utf_32_to_16_iterator const & lhs, utf_32_to_16_iterator const & rhs) noexcept -> decltype(lhs.base() == rhs.base()) @@ -2116,7 +2117,7 @@ namespace boost { namespace text { typename Iter2, typename Sentinel2, typename ErrorHandler> - BOOST_TEXT_CXX14_CONSTEXPR auto operator!=( + constexpr auto operator!=( utf_32_to_16_iterator const & lhs, utf_32_to_16_iterator const & rhs) noexcept -> decltype(!(lhs == rhs)) @@ -2126,7 +2127,7 @@ namespace boost { namespace text { /** An out iterator that converts UTF-8 to UTF-16. */ -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template Iter> #else template @@ -2226,7 +2227,7 @@ namespace boost { namespace text { /** A UTF-16 to UTF-32 converting iterator. */ -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template< utf16_iter I, std::sentinel_for S = I, @@ -2244,7 +2245,7 @@ namespace boost { namespace text { static bool const throw_on_error = !noexcept(std::declval()(0)); -#if !BOOST_TEXT_USE_CONCEPTS +#if !BOOST_PARSER_USE_CONCEPTS static_assert( std::is_same< typename std::iterator_traits::iterator_category, @@ -2266,7 +2267,7 @@ namespace boost { namespace text { : first_(first), it_(it), last_(last) {} -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template // clang-format off requires std::convertible_to && std::convertible_to @@ -2285,27 +2286,27 @@ namespace boost { namespace text { first_(other.first_), it_(other.it_), last_(other.last_) {} - BOOST_TEXT_CXX14_CONSTEXPR uint32_t operator*() const + constexpr uint32_t operator*() const noexcept(!throw_on_error) { - BOOST_ASSERT(!at_end(it_)); + BOOST_PARSER_DEBUG_ASSERT(!at_end(it_)); return get_value(*it_).value_; } - BOOST_TEXT_CXX14_CONSTEXPR I base() const noexcept { return it_; } + constexpr I base() const noexcept { return it_; } - BOOST_TEXT_CXX14_CONSTEXPR utf_16_to_32_iterator & + constexpr utf_16_to_32_iterator & operator++() noexcept(!throw_on_error) { - BOOST_ASSERT(it_ != last_); + BOOST_PARSER_DEBUG_ASSERT(it_ != last_); it_ = increment(); return *this; } - BOOST_TEXT_CXX14_CONSTEXPR utf_16_to_32_iterator & + constexpr utf_16_to_32_iterator & operator--() noexcept(!throw_on_error) { - BOOST_ASSERT(it_ != first_); + BOOST_PARSER_DEBUG_ASSERT(it_ != first_); if (boost::text::low_surrogate(*--it_)) { if (it_ != first_ && boost::text::high_surrogate(*std::prev(it_))) @@ -2333,7 +2334,7 @@ namespace boost { namespace text { I it_; }; - BOOST_TEXT_CXX14_CONSTEXPR bool at_end(I it) const + constexpr bool at_end(I it) const noexcept(!throw_on_error) { if (it == last_) { @@ -2346,7 +2347,7 @@ namespace boost { namespace text { } } - BOOST_TEXT_CXX14_CONSTEXPR get_value_result + constexpr get_value_result get_value(uint16_t curr) const noexcept(!throw_on_error) { uint32_t value = 0; @@ -2380,7 +2381,7 @@ namespace boost { namespace text { return get_value_result{value, next}; } - BOOST_TEXT_CXX14_CONSTEXPR I increment() const noexcept(!throw_on_error) + constexpr I increment() const noexcept(!throw_on_error) { return get_value(*it_).it_; } @@ -2389,7 +2390,7 @@ namespace boost { namespace text { I it_; S last_; -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template< utf32_iter I2, std::sentinel_for S2, @@ -2399,7 +2400,7 @@ namespace boost { namespace text { #endif friend struct utf_32_to_16_iterator; -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template< utf16_iter I2, std::sentinel_for S2, @@ -2413,7 +2414,7 @@ namespace boost { namespace text { }; template - BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + constexpr auto operator==( utf_16_to_32_iterator const & lhs, Sentinel rhs) noexcept -> decltype(lhs.base() == rhs) { @@ -2421,7 +2422,7 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + constexpr auto operator==( Sentinel lhs, utf_16_to_32_iterator const & rhs) noexcept -> decltype(rhs.base() == lhs) @@ -2430,7 +2431,7 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator!=( + constexpr auto operator!=( utf_16_to_32_iterator const & lhs, Sentinel rhs) noexcept -> decltype(lhs.base() != rhs) { @@ -2438,7 +2439,7 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator!=( + constexpr auto operator!=( Sentinel lhs, utf_16_to_32_iterator const & rhs) noexcept -> decltype(rhs.base() != lhs) @@ -2452,7 +2453,7 @@ namespace boost { namespace text { typename Iter2, typename Sentinel2, typename ErrorHandler> - BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + constexpr auto operator==( utf_16_to_32_iterator const & lhs, utf_16_to_32_iterator const & rhs) noexcept -> decltype(lhs.base() == rhs.base()) @@ -2466,7 +2467,7 @@ namespace boost { namespace text { typename Iter2, typename Sentinel2, typename ErrorHandler> - BOOST_TEXT_CXX14_CONSTEXPR auto operator!=( + constexpr auto operator!=( utf_16_to_32_iterator const & lhs, utf_16_to_32_iterator const & rhs) noexcept -> decltype(!(lhs == rhs)) @@ -2509,7 +2510,7 @@ namespace boost { namespace text { } /** An out iterator that converts UTF-16 to UTF-32. */ -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template Iter> #else template @@ -2633,7 +2634,7 @@ namespace boost { namespace text { /** A UTF-16 to UTF-8 converting iterator. */ -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template< utf16_iter I, std::sentinel_for S = I, @@ -2650,7 +2651,7 @@ namespace boost { namespace text { static bool const throw_on_error = !noexcept(std::declval()(0)); -#if !BOOST_TEXT_USE_CONCEPTS +#if !BOOST_PARSER_USE_CONCEPTS static_assert( std::is_same< typename std::iterator_traits::iterator_category, @@ -2669,14 +2670,14 @@ namespace boost { namespace text { constexpr utf_16_to_8_iterator() noexcept : first_(), it_(), last_(), index_(4), buf_() {} - explicit BOOST_TEXT_CXX14_CONSTEXPR + explicit constexpr utf_16_to_8_iterator(I first, I it, S last) noexcept : first_(first), it_(it), last_(last), index_(0), buf_() { if (it_ != last_) read_into_buf(); } -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template // clang-format off requires std::convertible_to && std::convertible_to @@ -2698,20 +2699,20 @@ namespace boost { namespace text { buf_(other.buf_) {} - BOOST_TEXT_CXX14_CONSTEXPR char operator*() const + constexpr char operator*() const noexcept(!throw_on_error) { return buf_[index_]; } - BOOST_TEXT_CXX14_CONSTEXPR I base() const noexcept { return it_; } + constexpr I base() const noexcept { return it_; } - BOOST_TEXT_CXX14_CONSTEXPR utf_16_to_8_iterator & + constexpr utf_16_to_8_iterator & operator++() noexcept(!throw_on_error) { ++index_; if (at_buf_end()) { - BOOST_ASSERT(it_ != last_); + BOOST_PARSER_DEBUG_ASSERT(it_ != last_); increment(); index_ = 0; if (it_ != last_) @@ -2720,13 +2721,13 @@ namespace boost { namespace text { return *this; } - BOOST_TEXT_CXX14_CONSTEXPR utf_16_to_8_iterator & + constexpr utf_16_to_8_iterator & operator--() noexcept(!throw_on_error) { if (0 < index_) { --index_; } else { - BOOST_ASSERT(it_ != first_); + BOOST_PARSER_DEBUG_ASSERT(it_ != first_); decrement(); auto out = read_into_buf(); index_ = out - buf_.data() - 1; @@ -2740,7 +2741,7 @@ namespace boost { namespace text { typename I2, typename S2, typename ErrorHandler2> - friend BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + friend constexpr auto operator==( utf_16_to_8_iterator const & lhs, utf_16_to_8_iterator const & rhs) noexcept -> decltype(lhs.base() == rhs.base()); @@ -2758,7 +2759,7 @@ namespace boost { namespace text { #ifndef BOOST_TEXT_DOXYGEN private: - BOOST_TEXT_CXX14_CONSTEXPR bool at_end() const noexcept(!throw_on_error) + constexpr bool at_end() const noexcept(!throw_on_error) { if (it_ == last_) { ErrorHandler{}( @@ -2775,7 +2776,7 @@ namespace boost { namespace text { return buf_[index_] == '\0'; } - BOOST_TEXT_CXX14_CONSTEXPR char * + constexpr char * read_into_buf() noexcept(!throw_on_error) { I next = it_; @@ -2807,7 +2808,7 @@ namespace boost { namespace text { return retval; } - BOOST_TEXT_CXX14_CONSTEXPR void increment() noexcept + constexpr void increment() noexcept { if (boost::text::high_surrogate(*it_)) { ++it_; @@ -2818,7 +2819,7 @@ namespace boost { namespace text { } } - BOOST_TEXT_CXX14_CONSTEXPR void decrement() noexcept + constexpr void decrement() noexcept { if (boost::text::low_surrogate(*--it_)) { if (it_ != first_) @@ -2837,7 +2838,7 @@ namespace boost { namespace text { static uint32_t const surrogate_offset = 0x10000 - (high_surrogate_min << 10) - low_surrogate_min; -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template< utf16_iter I2, std::sentinel_for S2, @@ -2850,7 +2851,7 @@ namespace boost { namespace text { }; template - BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + constexpr auto operator==( utf_16_to_8_iterator const & lhs, Sentinel rhs) noexcept -> decltype(lhs.base() == rhs) { @@ -2858,7 +2859,7 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + constexpr auto operator==( Sentinel lhs, utf_16_to_8_iterator const & rhs) noexcept -> decltype(rhs.base() == lhs) @@ -2867,7 +2868,7 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator!=( + constexpr auto operator!=( utf_16_to_8_iterator const & lhs, Sentinel rhs) noexcept -> decltype(lhs.base() != rhs) { @@ -2875,7 +2876,7 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator!=( + constexpr auto operator!=( Sentinel lhs, utf_16_to_8_iterator const & rhs) noexcept -> decltype(rhs.base() != lhs) @@ -2889,7 +2890,7 @@ namespace boost { namespace text { typename Iter2, typename Sentinel2, typename ErrorHandler> - BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + constexpr auto operator==( utf_16_to_8_iterator const & lhs, utf_16_to_8_iterator const & rhs) noexcept -> decltype(lhs.base() == rhs.base()) @@ -2903,7 +2904,7 @@ namespace boost { namespace text { typename Iter2, typename Sentinel2, typename ErrorHandler> - BOOST_TEXT_CXX14_CONSTEXPR auto operator!=( + constexpr auto operator!=( utf_16_to_8_iterator const & lhs, utf_16_to_8_iterator const & rhs) noexcept -> decltype(!(lhs == rhs)) @@ -2940,7 +2941,7 @@ namespace boost { namespace text { } /** An out iterator that converts UTF-16 to UTF-8. */ -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template Iter> #else template @@ -3062,7 +3063,7 @@ namespace boost { namespace text { }; -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template< utf8_iter I, std::sentinel_for S, @@ -3077,14 +3078,14 @@ namespace boost { namespace text { !noexcept(std::declval()(0)); constexpr utf_8_to_16_iterator() noexcept : it_(), index_(2), buf_() {} - explicit BOOST_TEXT_CXX14_CONSTEXPR + explicit constexpr utf_8_to_16_iterator(I first, I it, S last) noexcept : it_(first, it, last), index_(0), buf_() { if (it_.it_ != it_.last_) read_into_buf(); } -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template // clang-format off requires std::convertible_to && std::convertible_to @@ -3104,23 +3105,23 @@ namespace boost { namespace text { buf_(other.buf_) {} - BOOST_TEXT_CXX14_CONSTEXPR uint16_t operator*() const + constexpr uint16_t operator*() const noexcept(!throw_on_error) { return buf_[index_]; } - BOOST_TEXT_CXX14_CONSTEXPR I base() const noexcept + constexpr I base() const noexcept { return it_.base(); } - BOOST_TEXT_CXX14_CONSTEXPR utf_8_to_16_iterator & + constexpr utf_8_to_16_iterator & operator++() noexcept(!throw_on_error) { ++index_; if (at_buf_end()) { - BOOST_ASSERT(it_.it_ != it_.last_); + BOOST_PARSER_DEBUG_ASSERT(it_.it_ != it_.last_); ++it_; index_ = 0; if (it_.it_ != it_.last_) @@ -3129,13 +3130,13 @@ namespace boost { namespace text { return *this; } - BOOST_TEXT_CXX14_CONSTEXPR utf_8_to_16_iterator & + constexpr utf_8_to_16_iterator & operator--() noexcept(!throw_on_error) { if (0 < index_) { --index_; } else { - BOOST_ASSERT(it_.it_ != it_.first_); + BOOST_PARSER_DEBUG_ASSERT(it_.it_ != it_.first_); --it_; auto out = read_into_buf(); index_ = out - buf_.data() - 1; @@ -3149,7 +3150,7 @@ namespace boost { namespace text { typename I2, typename S2, typename ErrorHandler2> - friend BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + friend constexpr auto operator==( utf_8_to_16_iterator const & lhs, utf_8_to_16_iterator const & rhs) noexcept -> decltype(lhs.base() == rhs.base()); @@ -3169,7 +3170,7 @@ namespace boost { namespace text { private: constexpr bool at_buf_end() const noexcept { return buf_[index_] == 0; } - BOOST_TEXT_CXX14_CONSTEXPR uint16_t * + constexpr uint16_t * read_into_buf() noexcept(!throw_on_error) { auto const last = detail::write_cp_utf16(*it_, buf_.data()); @@ -3181,7 +3182,7 @@ namespace boost { namespace text { int index_; std::array buf_; -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template< utf8_iter I2, std::sentinel_for S2, @@ -3194,7 +3195,7 @@ namespace boost { namespace text { }; template - BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + constexpr auto operator==( utf_8_to_16_iterator const & lhs, Sentinel rhs) noexcept -> decltype(lhs.base() == rhs) { @@ -3202,7 +3203,7 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + constexpr auto operator==( Sentinel lhs, utf_8_to_16_iterator const & rhs) noexcept -> decltype(rhs.base() == lhs) @@ -3211,7 +3212,7 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator!=( + constexpr auto operator!=( utf_8_to_16_iterator const & lhs, Sentinel rhs) noexcept -> decltype(lhs.base() != rhs) { @@ -3219,7 +3220,7 @@ namespace boost { namespace text { } template - BOOST_TEXT_CXX14_CONSTEXPR auto operator!=( + constexpr auto operator!=( Sentinel lhs, utf_8_to_16_iterator const & rhs) noexcept -> decltype(rhs.base() != lhs) @@ -3233,7 +3234,7 @@ namespace boost { namespace text { typename Iter2, typename Sentinel2, typename ErrorHandler> - BOOST_TEXT_CXX14_CONSTEXPR auto operator==( + constexpr auto operator==( utf_8_to_16_iterator const & lhs, utf_8_to_16_iterator const & rhs) noexcept -> decltype(lhs.base() == rhs.base()) @@ -3247,7 +3248,7 @@ namespace boost { namespace text { typename Iter2, typename Sentinel2, typename ErrorHandler> - BOOST_TEXT_CXX14_CONSTEXPR auto operator!=( + constexpr auto operator!=( utf_8_to_16_iterator const & lhs, utf_8_to_16_iterator const & rhs) noexcept -> decltype(!(lhs == rhs)) @@ -3290,7 +3291,7 @@ namespace boost { namespace text { } /** An out iterator that converts UTF-8 to UTF-16. */ -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template Iter> #else template @@ -3417,7 +3418,7 @@ namespace boost { namespace text { }} -#include +#include namespace boost { namespace text { namespace detail { @@ -3609,7 +3610,7 @@ namespace boost { namespace text { namespace detail { }}} -namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V1 { +namespace boost { namespace text { BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V1 { /** Returns a `utf_32_to_8_out_iterator` constructed from the given iterator. */ @@ -3835,9 +3836,9 @@ namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V1 { }}} -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS -namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V2 { +namespace boost { namespace text { BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V2 { /** Returns a `utf_32_to_8_out_iterator` constructed from the given iterator. */ diff --git a/include/boost/text/transcode_view.hpp b/include/boost/parser/detail/text/transcode_view.hpp similarity index 96% rename from include/boost/text/transcode_view.hpp rename to include/boost/parser/detail/text/transcode_view.hpp index 3a256e79..f5f2cd08 100644 --- a/include/boost/text/transcode_view.hpp +++ b/include/boost/parser/detail/text/transcode_view.hpp @@ -3,13 +3,13 @@ // 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_TEXT_TRANSCODE_VIEW_HPP -#define BOOST_TEXT_TRANSCODE_VIEW_HPP +#ifndef BOOST_PARSER_DETAIL_TEXT_TRANSCODE_VIEW_HPP +#define BOOST_PARSER_DETAIL_TEXT_TRANSCODE_VIEW_HPP -#include -#include -#include -#include +#include +#include +#include +#include #include @@ -150,7 +150,7 @@ namespace boost { namespace text { } /** A view over UTF-8 code units. */ -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template S = I> #else template @@ -218,7 +218,7 @@ namespace boost { namespace text { }; /** A view over UTF-16 code units. */ -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template S = I> #else template @@ -286,7 +286,7 @@ namespace boost { namespace text { }; /** A view over UTF-32 code units. */ -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template S = I> #else template @@ -353,7 +353,7 @@ namespace boost { namespace text { }} -namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V1 { +namespace boost { namespace text { BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V1 { /** Returns a `utf8_view` over the data in `[first, last)`. The view will transcode the data if necessary. */ @@ -504,9 +504,9 @@ namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V1 { }}} -#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS +#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS -namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V2 { +namespace boost { namespace text { BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V2 { /** Returns a `utf8_view` over the data in `[first, last)`. The view will transcode the data if necessary. */ diff --git a/include/boost/text/trie.hpp b/include/boost/parser/detail/text/trie.hpp similarity index 96% rename from include/boost/text/trie.hpp rename to include/boost/parser/detail/text/trie.hpp index 159d2647..a6f404de 100644 --- a/include/boost/text/trie.hpp +++ b/include/boost/parser/detail/text/trie.hpp @@ -3,11 +3,11 @@ // 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_TEXT_TRIE_HPP -#define BOOST_TEXT_TRIE_HPP +#ifndef BOOST_PARSER_DETAIL_TEXT_TRIE_HPP +#define BOOST_PARSER_DETAIL_TEXT_TRIE_HPP -#include -#include +#include +#include #include #include @@ -35,7 +35,7 @@ namespace boost { namespace text { auto operator=(U && u) -> decltype(*this->t_ = static_cast(u), *this) { - BOOST_ASSERT(t_); + BOOST_PARSER_DEBUG_ASSERT(t_); *t_ = static_cast(u); return *this; } @@ -46,48 +46,48 @@ namespace boost { namespace text { T const & operator*() const noexcept { - BOOST_ASSERT(t_); + BOOST_PARSER_DEBUG_ASSERT(t_); return *t_; } T const * operator->() const noexcept { - BOOST_ASSERT(t_); + BOOST_PARSER_DEBUG_ASSERT(t_); return t_; } operator T const &() const & noexcept { - BOOST_ASSERT(t_); + BOOST_PARSER_DEBUG_ASSERT(t_); return *t_; } operator T const &() const && noexcept { - BOOST_ASSERT(t_); + BOOST_PARSER_DEBUG_ASSERT(t_); return *t_; } T & operator*() noexcept { - BOOST_ASSERT(t_); + BOOST_PARSER_DEBUG_ASSERT(t_); return *t_; } T * operator->() noexcept { - BOOST_ASSERT(t_); + BOOST_PARSER_DEBUG_ASSERT(t_); return t_; } operator T &() & noexcept { - BOOST_ASSERT(t_); + BOOST_PARSER_DEBUG_ASSERT(t_); return *t_; } operator T &() && noexcept { - BOOST_ASSERT(t_); + BOOST_PARSER_DEBUG_ASSERT(t_); return *t_; } }; @@ -108,24 +108,24 @@ namespace boost { namespace text { T & operator*() const noexcept { - BOOST_ASSERT(t_); + BOOST_PARSER_DEBUG_ASSERT(t_); return *t_; } T * operator->() const noexcept { - BOOST_ASSERT(t_); + BOOST_PARSER_DEBUG_ASSERT(t_); return t_; } operator T &() const & noexcept { - BOOST_ASSERT(t_); + BOOST_PARSER_DEBUG_ASSERT(t_); return *t_; } operator T &() const && noexcept { - BOOST_ASSERT(t_); + BOOST_PARSER_DEBUG_ASSERT(t_); return *t_; } }; @@ -144,7 +144,7 @@ namespace boost { namespace text { auto operator=(U && u) -> decltype(*this->t_ = static_cast(u), *this) { - BOOST_ASSERT(t_); + BOOST_PARSER_DEBUG_ASSERT(t_); *t_ = static_cast(u); return *this; } @@ -154,24 +154,24 @@ namespace boost { namespace text { bool const & operator*() const noexcept { - BOOST_ASSERT(t_); + BOOST_PARSER_DEBUG_ASSERT(t_); return *t_; } bool const * operator->() const noexcept { - BOOST_ASSERT(t_); + BOOST_PARSER_DEBUG_ASSERT(t_); return t_; } bool & operator*() noexcept { - BOOST_ASSERT(t_); + BOOST_PARSER_DEBUG_ASSERT(t_); return *t_; } bool * operator->() noexcept { - BOOST_ASSERT(t_); + BOOST_PARSER_DEBUG_ASSERT(t_); return t_; } }; @@ -191,12 +191,12 @@ namespace boost { namespace text { bool const & operator*() const noexcept { - BOOST_ASSERT(t_); + BOOST_PARSER_DEBUG_ASSERT(t_); return *t_; } bool const * operator->() const noexcept { - BOOST_ASSERT(t_); + BOOST_PARSER_DEBUG_ASSERT(t_); return t_; } }; @@ -214,7 +214,7 @@ namespace boost { namespace text { { std::size_t value() const noexcept { - BOOST_ASSERT(!"This should never be called."); + BOOST_PARSER_DEBUG_ASSERT(!"This should never be called."); return 0; } @@ -536,7 +536,7 @@ namespace boost { namespace text { match_result extend_match(match_result prev, KeyElementT e) const noexcept { - BOOST_ASSERT(prev.match); + BOOST_PARSER_DEBUG_ASSERT(prev.match); auto e_ptr = &e; return extend_subsequence_impl(prev, e_ptr, e_ptr + 1); } @@ -549,7 +549,7 @@ namespace boost { namespace text { extend_match(match_result prev, KeyIter first, Sentinel last) const noexcept { - BOOST_ASSERT(prev.match); + BOOST_PARSER_DEBUG_ASSERT(prev.match); return extend_subsequence_impl(prev, first, last); } @@ -908,7 +908,7 @@ namespace boost { namespace text { } trie_node_t & operator=(trie_node_t const & rhs) { - BOOST_ASSERT( + BOOST_PARSER_DEBUG_ASSERT( parent_ == nullptr && "Assignment of trie_node_ts are defined only for the " "header node."); @@ -918,7 +918,7 @@ namespace boost { namespace text { } trie_node_t & operator=(trie_node_t && rhs) { - BOOST_ASSERT( + BOOST_PARSER_DEBUG_ASSERT( parent_ == nullptr && "Move assignments of trie_node_ts are defined only for the " "header node."); @@ -981,7 +981,7 @@ namespace boost { namespace text { key_element const & key(std::size_t i) const noexcept { - BOOST_ASSERT(key_element(i) == i); + BOOST_PARSER_DEBUG_ASSERT(key_element(i) == i); return key_element(i); } @@ -1001,7 +1001,7 @@ namespace boost { namespace text { void swap(trie_node_t & other) { - BOOST_ASSERT( + BOOST_PARSER_DEBUG_ASSERT( parent_ == nullptr && "Swaps of trie_node_ts are defined only for the header " "node."); @@ -1055,7 +1055,7 @@ namespace boost { namespace text { [child](std::unique_ptr const & ptr) { return child == ptr.get(); }); - BOOST_ASSERT(it != children_.end()); + BOOST_PARSER_DEBUG_ASSERT(it != children_.end()); erase(it - children_.begin()); } @@ -1159,7 +1159,7 @@ namespace boost { namespace text { } trie_node_t & operator=(trie_node_t const & rhs) { - BOOST_ASSERT( + BOOST_PARSER_DEBUG_ASSERT( parent_ == nullptr && "Assignment of trie_node_ts are defined only for the " "header node."); @@ -1169,7 +1169,7 @@ namespace boost { namespace text { } trie_node_t & operator=(trie_node_t && rhs) { - BOOST_ASSERT( + BOOST_PARSER_DEBUG_ASSERT( parent_ == nullptr && "Move assignments of trie_node_ts are defined only for the " "header node."); @@ -1270,7 +1270,7 @@ namespace boost { namespace text { void swap(trie_node_t & other) { - BOOST_ASSERT( + BOOST_PARSER_DEBUG_ASSERT( parent_ == nullptr && "Swaps of trie_node_ts are defined only for the header " "node."); @@ -1297,7 +1297,7 @@ namespace boost { namespace text { Compare const & comp, std::unique_ptr && child) { - BOOST_ASSERT(child->empty()); + BOOST_PARSER_DEBUG_ASSERT(child->empty()); auto it = std::lower_bound(keys_.begin(), keys_.end(), e, comp); it = keys_.insert(it, e); auto const offset = it - keys_.begin(); @@ -1308,7 +1308,7 @@ namespace boost { namespace text { } iterator insert(std::unique_ptr && child) { - BOOST_ASSERT(empty()); + BOOST_PARSER_DEBUG_ASSERT(empty()); index_within_parent_.insert_ptr(child); return children_.insert(children_.begin(), std::move(child)); } @@ -1328,7 +1328,7 @@ namespace boost { namespace text { [child](std::unique_ptr const & ptr) { return child == ptr.get(); }); - BOOST_ASSERT(it != children_.end()); + BOOST_PARSER_DEBUG_ASSERT(it != children_.end()); erase(it - children_.begin()); } diff --git a/include/boost/text/trie_fwd.hpp b/include/boost/parser/detail/text/trie_fwd.hpp similarity index 90% rename from include/boost/text/trie_fwd.hpp rename to include/boost/parser/detail/text/trie_fwd.hpp index ca2ccf30..5523dc6a 100644 --- a/include/boost/text/trie_fwd.hpp +++ b/include/boost/parser/detail/text/trie_fwd.hpp @@ -3,8 +3,8 @@ // 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_TEXT_TRIE_FWD_HPP -#define BOOST_TEXT_TRIE_FWD_HPP +#ifndef BOOST_PARSER_DETAIL_TEXT_TRIE_FWD_HPP +#define BOOST_PARSER_DETAIL_TEXT_TRIE_FWD_HPP namespace boost { namespace text { diff --git a/include/boost/text/utf.hpp b/include/boost/parser/detail/text/utf.hpp similarity index 87% rename from include/boost/text/utf.hpp rename to include/boost/parser/detail/text/utf.hpp index d625a63e..d5ee4055 100644 --- a/include/boost/text/utf.hpp +++ b/include/boost/parser/detail/text/utf.hpp @@ -3,10 +3,10 @@ // 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_TEXT_UTF_HPP -#define BOOST_TEXT_UTF_HPP +#ifndef BOOST_PARSER_DETAIL_TEXT_UTF_HPP +#define BOOST_PARSER_DETAIL_TEXT_UTF_HPP -#include +#include #include diff --git a/include/boost/parser/error_handling.hpp b/include/boost/parser/error_handling.hpp index e676bc95..44d279c8 100644 --- a/include/boost/parser/error_handling.hpp +++ b/include/boost/parser/error_handling.hpp @@ -4,8 +4,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/include/boost/parser/error_handling_fwd.hpp b/include/boost/parser/error_handling_fwd.hpp index 1350c416..86620e02 100644 --- a/include/boost/parser/error_handling_fwd.hpp +++ b/include/boost/parser/error_handling_fwd.hpp @@ -3,7 +3,7 @@ #include -#include +#include #include #include diff --git a/include/boost/parser/parser.hpp b/include/boost/parser/parser.hpp index aa6f7d94..0f4cc5bc 100644 --- a/include/boost/parser/parser.hpp +++ b/include/boost/parser/parser.hpp @@ -12,8 +12,8 @@ #include #include #endif -#include -#include +#include +#include #include #include @@ -354,7 +354,7 @@ namespace boost { namespace parser { // = 0; }` may be fine. If you attach that same semantic action // to `eps`, you end up here, because `eps` has no attribute, and // so `_attr(ctx)` produces a `none`. - BOOST_ASSERT(false); + BOOST_PARSER_DEBUG_ASSERT(false); } }; #endif @@ -2492,7 +2492,7 @@ namespace boost { namespace parser { // It looks like you've created a repeated epsilon parser, by // writing "*eps", "+eps", "repeat(2, Inf)[eps]", or similar. - BOOST_ASSERT( + BOOST_PARSER_DEBUG_ASSERT( !detail::is_unconditional_eps{} || end < Inf); for (; count != end; ++count) { @@ -2570,7 +2570,7 @@ namespace boost { namespace parser { // It looks like you've created a repeated epsilon parser, by // writing "*eps", "+eps", "repeat(2, Inf)[eps]", or similar. - BOOST_ASSERT( + BOOST_PARSER_DEBUG_ASSERT( !detail::is_unconditional_eps{} || end < Inf); for (; count != end; ++count) { diff --git a/include/boost/parser/parser_fwd.hpp b/include/boost/parser/parser_fwd.hpp index ca870e57..bcc775b4 100644 --- a/include/boost/parser/parser_fwd.hpp +++ b/include/boost/parser/parser_fwd.hpp @@ -53,8 +53,8 @@ namespace boost { namespace parser { template T & cast() const { - BOOST_ASSERT(impl_); - BOOST_ASSERT(dynamic_cast *>(impl_.get())); + BOOST_PARSER_DEBUG_ASSERT(impl_); + BOOST_PARSER_DEBUG_ASSERT(dynamic_cast *>(impl_.get())); return static_cast *>(impl_.get())->value_; } diff --git a/include/boost/text/config.hpp b/include/boost/text/config.hpp deleted file mode 100644 index 8cb73412..00000000 --- a/include/boost/text/config.hpp +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright (C) 2020 T. Zachary Laine -// -// 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_TEXT_CONFIG_HPP -#define BOOST_TEXT_CONFIG_HPP - -#include - -// Included for definition of __cpp_lib_concepts. -#include - - -/** When you insert into a rope, the incoming sequence may be inserted as a - new segment, or if it falls within an existing string-segment, it may be - inserted into the string object used to represent that segment. This only - happens if the incoming sequence will fit within the existing segment's - capacity, or if the segment is smaller than a certain limit. - BOOST_TEXT_STRING_INSERT_MAX is that limit. */ -#ifndef BOOST_TEXT_STRING_INSERT_MAX -# define BOOST_TEXT_STRING_INSERT_MAX 4096 -#endif - -#if defined(__cpp_lib_concepts) && !defined(BOOST_TEXT_DISABLE_CONCEPTS) -# define BOOST_TEXT_USE_CONCEPTS 1 -#else -# define BOOST_TEXT_USE_CONCEPTS 0 -#endif - -#if defined(__cpp_coroutines) && !defined(BOOST_TEXT_DISABLE_COROUTINES) -# define BOOST_TEXT_USE_COROUTINES 1 -#else -# define BOOST_TEXT_USE_COROUTINES 0 -#endif - -#ifndef BOOST_TEXT_DOXYGEN - -// The inline namespaces v1 and v2 represent pre- and post-C++20. v1 is -// inline for standards before C++20, and v2 is inline for C++20 and later. -// Note that this only applies to code for which a v2 namespace alternative -// exists. Some instances of the v1 namespace may still be inline, if there -// is no v2 version of its contents. -#if BOOST_TEXT_USE_CONCEPTS -# define BOOST_TEXT_NAMESPACE_V1 namespace v1 -# define BOOST_TEXT_NAMESPACE_V2 inline namespace v2 -#else -# define BOOST_TEXT_NAMESPACE_V1 inline namespace v1 -# define BOOST_TEXT_NAMESPACE_V2 namespace v2 -#endif - -// Nothing before GCC 6 has proper C++14 constexpr support. -#if defined(__GNUC__) && __GNUC__ < 6 && !defined(__clang__) -# define BOOST_TEXT_CXX14_CONSTEXPR -# define BOOST_TEXT_NO_CXX14_CONSTEXPR -#elif defined(_MSC_VER) && _MSC_VER <= 1916 -# define BOOST_TEXT_CXX14_CONSTEXPR -# define BOOST_TEXT_NO_CXX14_CONSTEXPR -#else -# define BOOST_TEXT_CXX14_CONSTEXPR BOOST_CXX14_CONSTEXPR -# if defined(BOOST_NO_CXX14_CONSTEXPR) -# define BOOST_TEXT_NO_CXX14_CONSTEXPR -# endif -#endif - -// Implements separate compilation features as described in -// http://www.boost.org/more/separate_compilation.html - -// normalize macros - -#if !defined(BOOST_TEXT_DYN_LINK) && !defined(BOOST_TEXT_STATIC_LINK) && \ - !defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_ALL_STATIC_LINK) -# define BOOST_TEXT_STATIC_LINK -#endif - -#if defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_TEXT_DYN_LINK) -# define BOOST_TEXT_DYN_LINK -#elif defined(BOOST_ALL_STATIC_LINK) && !defined(BOOST_TEXT_STATIC_LINK) -# define BOOST_TEXT_STATIC_LINK -#endif - -#if defined(BOOST_TEXT_DYN_LINK) && defined(BOOST_TEXT_STATIC_LINK) -# error Must not define both BOOST_TEXT_DYN_LINK and BOOST_TEXT_STATIC_LINK -#endif - -// enable dynamic or static linking as requested - -#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_TEXT_DYN_LINK) -# if defined(BOOST_TEXT_SOURCE) -# define BOOST_TEXT_DECL BOOST_SYMBOL_EXPORT -# else -# define BOOST_TEXT_DECL BOOST_SYMBOL_IMPORT -# endif -#else -# define BOOST_TEXT_DECL -#endif - -#if 0 // TODO: Disabled for now. -// enable automatic library variant selection - -#if !defined(BOOST_TEXT_SOURCE) && !defined(BOOST_ALL_NO_LIB) && \ - !defined(BOOST_TEXT_NO_LIB) -// -// Set the name of our library, this will get undef'ed by auto_link.hpp -// once it's done with it: -// -#define BOOST_LIB_NAME boost_text -// -// If we're importing code from a dll, then tell auto_link.hpp about it: -// -#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_TEXT_DYN_LINK) -# define BOOST_DYN_LINK -#endif -// -// And include the header that does the work: -// -#include -#endif // auto-linking disabled -#endif - -#endif // doxygen - -#endif