diff --git a/.travis.yml b/.travis.yml index ca8ab93..5d47642 100644 --- a/.travis.yml +++ b/.travis.yml @@ -99,8 +99,8 @@ anchors: "libc6-dbg", "libc++-dev", "libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-8", - "ubuntu-toolchain-r-test" ] } } - + "ubuntu-toolchain-r-test" ] } } + gcc-48: &gcc-48 { apt: { packages: [ "g++-4.8" ] } } gcc-49: &gcc-49 { apt: { packages: [ "g++-4.9" ], sources: [ "ubuntu-toolchain-r-test" ] } } gcc-5: &gcc-5 { apt: { packages: [ "g++-5" ] } } @@ -190,7 +190,7 @@ jobs: - { os: "linux", env: [ "B2_TOOLSET=clang-6.0", "B2_CXXSTD=14,17" ], addons: *clang-6 } - { os: "linux", env: [ "B2_TOOLSET=clang-7", "B2_CXXSTD=17" ], addons: *clang-7 } - { os: "linux", env: [ "B2_TOOLSET=clang-8", "B2_CXXSTD=17" ], addons: *clang-8 } - + - os: "linux" env: ["B2_TOOLSET=clang-9", "B2_CXXSTD=11,14,17"] addons: @@ -203,8 +203,8 @@ jobs: - clang-9 - libc6-dbg - libc++-dev - - libstdc++-8-dev - + - libstdc++-8-dev + # libc++ - { os: "linux", env: [ "B2_TOOLSET=clang-6.0", "B2_CXXSTD=11,14", "B2_CXXFLAGS=-stdlib=libc++" ], addons: *clang-6 } @@ -246,7 +246,7 @@ jobs: script: - cd $BOOST_ROOT/libs/$SELF - ci/travis/coverity.sh - + # Standalone tests for StaticString - { os: "linux", env: [ "COMMENT=STANDALONE", "B2_TOOLSET=gcc-7", "B2_DEFINES=define=BOOST_STATIC_STRING_STANDALONE", "B2_CXXSTD=17" ], addons: *gcc-7 } - { os: "linux", env: [ "COMMENT=STANDALONE", "B2_TOOLSET=gcc-8", "B2_DEFINES=define=BOOST_STATIC_STRING_STANDALONE", "B2_CXXSTD=17" ], addons: *gcc-8 } @@ -267,9 +267,9 @@ jobs: - libc6-dbg - libc++-dev - libstdc++-8-dev - + - { os: "osx" , env: [ "COMMENT=STANDALONE", "B2_TOOLSET=clang", "B2_DEFINES=define=BOOST_STATIC_STRING_STANDALONE", "B2_CXXSTD=17" ] } - + notifications: email: false diff --git a/include/boost/static_string/config.hpp b/include/boost/static_string/config.hpp index b2f502c..02b3ad5 100644 --- a/include/boost/static_string/config.hpp +++ b/include/boost/static_string/config.hpp @@ -20,7 +20,7 @@ #endif // Include if we can -#ifdef __has_include +#ifdef __has_include #if __has_include() #include #endif @@ -45,7 +45,7 @@ #define BOOST_STATIC_STRING_CHECK_FOR_ATTR(x) __has_cpp_attribute(x) #elif defined(__has_attribute) #define BOOST_STATIC_STRING_CHECK_FOR_ATTR(x) __has_attribute(x) -#else +#else #define BOOST_STATIC_STRING_CHECK_FOR_ATTR(x) 0 #endif diff --git a/include/boost/static_string/static_string.hpp b/include/boost/static_string/static_string.hpp index e3328f4..7d2d87f 100644 --- a/include/boost/static_string/static_string.hpp +++ b/include/boost/static_string/static_string.hpp @@ -83,7 +83,7 @@ template void is_nothrow_convertible_helper(To) noexcept; // MSVC is unable to parse this as a single expression, so a helper is needed -template(std::declval()))> struct is_nothrow_convertible_msvc_helper { @@ -100,7 +100,7 @@ struct is_nothrow_convertible::value>::type> : std::true_type { }; -// GCC 4.8, 4.9 workaround for void_t to make the defining-type-id dependant +// GCC 4.8, 4.9 workaround for void_t to make the defining-type-id dependant template struct void_t_helper { @@ -120,7 +120,7 @@ template struct enable_if_viewable>::value && - !std::is_convertible::value>::type> + !std::is_convertible::value>::type> { using type = void; }; @@ -133,8 +133,8 @@ template struct is_iterator : std::false_type { }; template -struct is_iterator::value, +struct is_iterator::value, void_t>::type> : std::true_type { }; @@ -146,8 +146,8 @@ template struct is_input_iterator : std::false_type { }; template -struct is_input_iterator::value && - std::is_convertible::iterator_category, +struct is_input_iterator::value && + std::is_convertible::iterator_category, std::input_iterator_tag>::value>::type> : std::true_type { }; @@ -156,12 +156,12 @@ struct is_forward_iterator : std::false_type { }; template struct is_forward_iterator::value && - std::is_convertible::iterator_category, + std::is_convertible::iterator_category, std::forward_iterator_tag>::value>::type> : std::true_type { }; template -struct is_subtractable +struct is_subtractable : std::false_type { }; template @@ -172,7 +172,7 @@ struct is_subtractable() - std::declval( template< typename ForwardIt, typename std::enable_if::value>::type* = nullptr> -BOOST_STATIC_STRING_CPP14_CONSTEXPR +BOOST_STATIC_STRING_CPP14_CONSTEXPR std::size_t distance(ForwardIt first, ForwardIt last) { @@ -184,7 +184,7 @@ distance(ForwardIt first, ForwardIt last) template< typename RandomIt, typename std::enable_if::value>::type* = nullptr> -BOOST_STATIC_STRING_CPP14_CONSTEXPR +BOOST_STATIC_STRING_CPP14_CONSTEXPR std::size_t distance(RandomIt first, RandomIt last) { @@ -477,8 +477,8 @@ count_digits(std::size_t value) return value < 10 ? 1 : count_digits(value / 10) + 1; } -// Ignore -Wformat-truncation, we know what -// we are doing here. The version check does +// Ignore -Wformat-truncation, we know what +// we are doing here. The version check does // not need to be extremely precise. #if defined(__GNUC__) && __GNUC__ >= 7 #pragma GCC diagnostic push @@ -500,9 +500,9 @@ to_static_string_float_impl(double value) noexcept // we assume that the result is always positive if (std::size_t(std::snprintf(buffer, N + 1, "%f", value)) > N) { - // the + 4 is for the decimal, 'e', + // the + 4 is for the decimal, 'e', // its sign, and the sign of the integral portion - const int reserved_count = + const int reserved_count = (std::max)(2, count_digits( std::numeric_limits::max_exponent10)) + 4; const int precision = narrow > reserved_count ? @@ -531,7 +531,7 @@ to_static_string_float_impl(long double value) noexcept // we assume that the result is always positive if (std::size_t(std::snprintf(buffer, N + 1, "%Lf", value)) > N) { - // the + 4 is for the decimal, 'e', + // the + 4 is for the decimal, 'e', // its sign, and the sign of the integral portion const int reserved_count = (std::max)(2, count_digits( @@ -568,12 +568,12 @@ to_static_wstring_float_impl(double value) noexcept if (num_written < 0 || num_written > narrow) { - // the + 4 is for the decimal, 'e', + // the + 4 is for the decimal, 'e', // its sign, and the sign of the integral portion const int reserved_count = (std::max)(2, count_digits( std::numeric_limits::max_exponent10)) + 4; - const int precision = narrow > reserved_count ? + const int precision = narrow > reserved_count ? N - reserved_count : 0; // switch to scientific notation std::swprintf(buffer, N + 1, L"%.*e", precision, value); @@ -605,7 +605,7 @@ to_static_wstring_float_impl(long double value) noexcept if (num_written < 0 || num_written > narrow) { - // the + 4 is for the decimal, 'e', + // the + 4 is for the decimal, 'e', // its sign, and the sign of the integral portion const int reserved_count = (std::max)(2, count_digits( @@ -628,9 +628,9 @@ BOOST_STATIC_STRING_CPP14_CONSTEXPR inline ForwardIterator find_not_of( - ForwardIterator first, - ForwardIterator last, - const CharT* str, + ForwardIterator first, + ForwardIterator last, + const CharT* str, std::size_t n) noexcept { for (; first != last; ++first) @@ -641,9 +641,9 @@ find_not_of( // constexpr search for C++14 template -BOOST_STATIC_STRING_CPP14_CONSTEXPR +BOOST_STATIC_STRING_CPP14_CONSTEXPR inline -ForwardIt1 +ForwardIt1 search( ForwardIt1 first, ForwardIt1 last, @@ -669,7 +669,7 @@ search( template BOOST_STATIC_STRING_CPP14_CONSTEXPR inline -InputIt +InputIt find_first_of( InputIt first, InputIt last, @@ -686,7 +686,7 @@ find_first_of( // KRYSTIAN TODO: add a constexpr rotate -// Check if a pointer lies within the range {src_first, src_last) +// Check if a pointer lies within the range {src_first, src_last) // without unspecified behavior, allowing it to be used // in a constant evaluation. template @@ -694,14 +694,14 @@ BOOST_STATIC_STRING_CPP14_CONSTEXPR inline bool ptr_in_range( - const T* src_first, + const T* src_first, const T* src_last, const T* ptr) { #if defined(BOOST_STATIC_STRING_CPP14) && \ defined(BOOST_STATIC_STRING_IS_CONST_EVAL) // Our second best option is to use is_constant_evaluated - // and a loop that checks for equality, since equality for + // and a loop that checks for equality, since equality for // pointer to object types is never unspecified in this case. if (BOOST_STATIC_STRING_IS_CONST_EVAL) { @@ -718,12 +718,12 @@ defined(BOOST_STATIC_STRING_IS_CONST_EVAL) // We don't care about this in C++11, since this function would have // no applications in constant expressions. #if defined(BOOST_STATIC_STRING_CPP14) && \ -defined(BOOST_STATIC_STRING_NO_PTR_COMP_FUNCTIONS) +defined(BOOST_STATIC_STRING_NO_PTR_COMP_FUNCTIONS) // If library comparison functions don't work, // we can use try builtin comparison operators instead. return ptr >= src_first && ptr < src_last; #else - // Use the library comparison functions if we can't use + // Use the library comparison functions if we can't use // is_constant_evaluated or if we don't need to. return std::greater_equal()(ptr, src_first) && std::less()(ptr, src_last); @@ -780,25 +780,25 @@ throw_exception(const char* msg) @code template - using static_string = + using static_string = basic_static_string>; @endcode @code template - using static_wstring = + using static_wstring = basic_static_string>; @endcode - + @code template - using static_u16string = + using static_u16string = basic_static_string>; @endcode @code template - using static_u32string = + using static_u32string = basic_static_string>; @endcode @@ -810,11 +810,11 @@ throw_exception(const char* msg) basic_static_string>; @endcode - @see to_static_string + @see to_static_string */ template> -class basic_static_string +class basic_static_string #ifndef BOOST_STATIC_STRING_DOCS : private detail::static_string_base #endif @@ -858,11 +858,11 @@ public: /// The constant iterator type. using const_iterator = const value_type*; - + /// The reverse iterator type. using reverse_iterator = std::reverse_iterator; - + /// The constant reverse iterator type. using const_reverse_iterator = std::reverse_iterator; @@ -902,9 +902,9 @@ public: } /** Constructor. - + Construct the string with `count` copies of character `ch`. - + The behavior is undefined if `count >= npos` */ BOOST_STATIC_STRING_CPP14_CONSTEXPR @@ -916,7 +916,7 @@ public: } /** Constructor. - + Construct with a substring (pos, other.size()) of `other`. */ template @@ -929,7 +929,7 @@ public: } /** Constructor. - + Construct with a substring (pos, count) of `other`. */ template @@ -943,7 +943,7 @@ public: } /** Constructor. - + Construct with the first `count` characters of `s`, including nulls. */ BOOST_STATIC_STRING_CPP14_CONSTEXPR @@ -955,7 +955,7 @@ public: } /** Constructor. - + Construct from a null terminated string. */ BOOST_STATIC_STRING_CPP14_CONSTEXPR @@ -965,7 +965,7 @@ public: } /** Constructor. - + Construct from a range of characters */ template @@ -1007,7 +1007,7 @@ public: } /** Constructor. - + Construct from an initializer list */ BOOST_STATIC_STRING_CPP14_CONSTEXPR @@ -1017,7 +1017,7 @@ public: } /** Constructor. - + Construct from a object convertible to `string_view_type` */ template max_size()`. */ BOOST_STATIC_STRING_CPP14_CONSTEXPR @@ -1245,17 +1245,17 @@ public: Replaces the contents with those of the string `s`. - + @par Complexity Linear in `s.size()`. @par Exception Safety - + Strong guarantee. @tparam M The size of the other string. - + @return `*this` @param s The string to replace @@ -1285,7 +1285,7 @@ public: return assign_unchecked(s.data(), s.size()); } - template N)>::type* = nullptr> BOOST_STATIC_STRING_CPP14_CONSTEXPR basic_static_string& @@ -1314,7 +1314,7 @@ public: @param s The string to replace the contents with. - + @param pos The index at which to begin the substring. @param count The size of the substring. The default @@ -1336,25 +1336,25 @@ public: /** Assign to the string. Replaces the contents with those of `{s, s + count)`. - + @par Complexity - + Linear in `count`. - + @par Exception Safety - + Strong guarantee. - + @note - + The range can contain null characters. - + @return `*this` - + @param count The number of characters to copy. - + @param s A pointer to the string to copy from. - + @throw std::length_error `count > max_size()`. */ BOOST_STATIC_STRING_CPP14_CONSTEXPR @@ -1401,15 +1401,15 @@ public: @par Exception Safety Strong guarantee. - + @tparam InputIterator The type of the iterators. - + @par Constraints - + `InputIterator` satisfies __InputIterator__. - + @return `*this` - + @param first An iterator referring to the first character to assign. @@ -1437,15 +1437,15 @@ public: initializer list `ilist`. @par Complexity - + Linear in `init.size()`. - + @par Exception Safety - + Strong guarantee. - + @return `*this` - + @param ilist The initializer list to copy from. @throw std::length_error `ilist.size() > max_size()`. @@ -1459,22 +1459,22 @@ public: } /** Assign to the string. - + Replaces the contents with those of `sv`, where `sv` is `string_view_type(t)`. - + @par Complexity - + Linear in `sv.size()`. - + @par Exception Safety - + Strong guarantee. - + @note - + The view can contain null characters. - + @tparam T A type convertible to `string_view_type`. @par Constraints @@ -1485,9 +1485,9 @@ public: @endcode @return `*this` - + @param t The object to assign from. - + @throw std::length_error `sv.size() > max_size()`. */ template= size()` */ BOOST_STATIC_STRING_CPP14_CONSTEXPR @@ -1623,11 +1623,11 @@ public: @par Complexity Constant. - + @par Precondition `pos >= size` - + @param pos The index to access. */ BOOST_STATIC_STRING_CPP14_CONSTEXPR @@ -1660,15 +1660,15 @@ public: } /** Return the first character. - + Returns a reference to the first character. - + @par Complexity - + Constant. - + @par Precondition - + `not empty()` */ BOOST_STATIC_STRING_CPP14_CONSTEXPR @@ -1743,9 +1743,9 @@ public: valid range, even if the container is empty. @par Complexity - + Constant. - + @note The value returned from this function is never never a null pointer value. */ @@ -1804,7 +1804,7 @@ public: underlying character string. @par Complexity - + Constant. */ BOOST_STATIC_STRING_CPP11_CONSTEXPR @@ -1928,7 +1928,7 @@ public: @par Complexity Constant. - + @return `size() == 0` */ BOOST_STATIC_STRING_NODISCARD @@ -2017,9 +2017,9 @@ public: { return max_size(); } - + /** Request the removal of unused capacity. - + This function has no effect. */ BOOST_STATIC_STRING_CPP14_CONSTEXPR @@ -2033,7 +2033,7 @@ public: //-------------------------------------------------------------------------- /** Clear the contents. - + Erases all characters from the string. After this call, @ref size() returns zero. @@ -2087,7 +2087,7 @@ public: insert(begin() + index, count, ch); return *this; } - + /** Insert into the string. Inserts the null-terminated character string pointed to by `s` @@ -2347,7 +2347,7 @@ public: @par Constraints - `InputIterator` satisfies __InputIterator__ and does not + `InputIterator` satisfies __InputIterator__ and does not satisfy __ForwardIterator__. @return An iterator which refers to the first inserted character @@ -2366,7 +2366,7 @@ public: #else typename std::enable_if< detail::is_input_iterator< - InputIterator>::value && + InputIterator>::value && !detail::is_forward_iterator< InputIterator>::value, iterator>::type #endif @@ -2380,7 +2380,7 @@ public: BOOST_STATIC_STRING_CPP14_CONSTEXPR typename std::enable_if< detail::is_forward_iterator< - ForwardIterator>::value, + ForwardIterator>::value, iterator>::type insert( const_iterator pos, @@ -2523,18 +2523,18 @@ public: `num` is determined as the smaller of `count` and `size() - index`. @par Exception Safety - + Strong guarantee. - + @note All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated. - + @return `*this` - + @param index The index to erase at. The default argument for this parameter is `0`. - + @param count The number of characters to erase. The default argument for this parameter is @ref npos. @@ -2553,22 +2553,22 @@ public: /** Erase from the string. Erases the character at `pos`. - + @par Preconditions - + `pos` shall be valid within `{data(), data() + size()}` - + @par Exception Safety - + Strong guarantee. - + @note All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated. - + @return An iterator referring to character immediately following the erased character, or @ref end() if one does not exist. - + @param pos An iterator referring to the character to erase. */ BOOST_STATIC_STRING_CPP14_CONSTEXPR @@ -2588,18 +2588,18 @@ public: `{first, last}` shall be valid within `{data(), data() + size()}` @par Exception Safety - + Strong guarantee. - + @note All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated. - + @return An iterator referring to the character `last` previously referred to, or @ref end() if one does not exist. - + @param first An iterator referring to the first character to erase. - + @param last An iterator past the last character to erase. */ BOOST_STATIC_STRING_CPP14_CONSTEXPR @@ -2613,7 +2613,7 @@ public: Appends a character to the end of the string. @par Exception Safety - + Strong guarantee. @param ch The character to append. @@ -2627,7 +2627,7 @@ public: /** Remove the last character. Removes a character from the end of the string. - + @par Precondition `not empty()` @@ -2648,13 +2648,13 @@ public: @par Exception Safety Strong guarantee. - + @return `*this` - + @param count The number of characters to append. - + @param ch The character to append. - + @throw std::length_error `size() + count > max_size()` */ BOOST_STATIC_STRING_CPP14_CONSTEXPR @@ -2668,15 +2668,15 @@ public: Appends `s` to the end of the string. @par Exception Safety - + Strong guarantee. - + @tparam M The size of the string to append. @return `*this` - + @param s The string to append. - + @throw std::length_error `size() + s.size() > max_size()` */ template @@ -2732,13 +2732,13 @@ public: Strong guarantee. @note The string can contain null characters. - + @return `*this` - + @param s The string to append. - + @param count The number of characters to append. - + @throw std::length_error `size() + count > max_size()` */ BOOST_STATIC_STRING_CPP14_CONSTEXPR @@ -2779,25 +2779,25 @@ public: @par Precondition `{first, last)` shall be a valid range - + @par Exception Safety - + Strong guarantee. - + @tparam InputIterator The type of the iterators. - + @par Constraints `InputIterator` satisfies __InputIterator__. - + @return `*this` - + @param first An iterator referring to the first character to append. - + @param last An iterator past the end of last character to append. - + @throw std::length_error `size() + std::distance(first, last) > max_size()` */ template @@ -2818,18 +2818,18 @@ public: } /** Append to the string. - + Appends the characters from `ilist` to the end of the string. - + @par Exception Safety - + Strong guarantee. - + @return `*this` - + @param ilist The initializer list to append. - + @throw std::length_error `size() + ilist.size() > max_size()` */ BOOST_STATIC_STRING_CPP14_CONSTEXPR @@ -2848,18 +2848,18 @@ public: @par Exception Safety Strong guarantee. - + @tparam T The type of the object to convert. - + @par Constraints @code - std::is_convertible::value && + std::is_convertible::value && !std::is_convertible::value @endcode @return `*this` - + @param t The string to append. @throw std::length_error `size() + sv.size() > max_size()` @@ -2898,9 +2898,9 @@ public: @return `*this` @param t The object to append. - + @param pos The index at which to begin the substring. - + @param count The size of the substring. The default argument for this parameter is @ref npos. @@ -3060,7 +3060,7 @@ public: Linear. @return The result of lexicographically comparing `s` and the string. - + @tparam M The size of the string to compare with. @param s The string to compare. @@ -3084,23 +3084,23 @@ public: otherwise. @par Complexity - + Linear. - + @par Exception Safety - + Strong guarantee. - - @return The result of lexicographically comparing `sub` and `s`. + + @return The result of lexicographically comparing `sub` and `s`. @tparam M The size of the string to compare with. @param pos1 The index at which to begin the substring. - + @param count1 The size of the substring. - + @param s The string to compare. - + @throw std::out_of_range `pos1 > size()` */ template @@ -3125,7 +3125,7 @@ public: otherwise. @par Complexity - + Linear. @par Exception Safety @@ -3133,19 +3133,19 @@ public: Strong guarantee. @return The result of lexicographically comparing `sub1` and `sub2`. - + @param pos1 The index at which to begin the substring. - + @param count1 The size of the substring. - + @param s The string to compare. - + @param pos2 The index at which to begin the substring to compare. - + @param count2 The size of the substring to compare. - + @throw std::out_of_range `pos1 > size()` - + @throw std::out_of_range `pos2 > s.size()` */ template @@ -3159,24 +3159,24 @@ public: size_type count2 = npos) const { return detail::lexicographical_compare( - data() + pos1, capped_length(pos1, count1), + data() + pos1, capped_length(pos1, count1), s.data() + pos2, s.capped_length(pos2, count2)); } /** Compare a string with the string. - + Let `len` be `traits_type::length(s)` and `comp` be `traits_type::compare(data(), s, std::min(size(), len)`. If `comp != 0`, then the result is `comp`. Otherwise, the result is `0` if `size() == len`, `-1` if `size() < len`, and `1` otherwise. - + @par Complexity - + Linear. @return The result of lexicographically comparing `s` and the string. - + @param s The string to compare. */ BOOST_STATIC_STRING_CPP14_CONSTEXPR @@ -3188,28 +3188,28 @@ public: } /** Compare a string with the string. - + Let `sub` be `substr(pos1, count1)`, `len` be `traits_type::length(s)`, and `comp` be `traits_type::compare(sub.data(), s, std::min(size(), len)`. If `comp != 0`, then the result is `comp`. Otherwise, the result is `0` if `sub.size() == len`, `-1` if `sub.size() < len`, and `1` otherwise. - + @par Complexity - + Linear. - + @par Exception Safety - + Strong guarantee. @return The result of lexicographically comparing `s` and `sub`. - + @param pos1 The index at which to begin the substring. - + @param count1 The size of the substring. - + @param s The string to compare. @throw std::out_of_range `pos1 > size()` @@ -3272,15 +3272,15 @@ public: If `comp != 0`, then the result is `comp`. Otherwise, the result is `0` if `size() == s.size()`, `-1` if `size() < s.size()`, and `1` otherwise. - + @par Complexity - + Linear. @par Exception Safety Strong guarantee. - + @tparam T The type of the object to convert. @par Constraints @@ -3291,7 +3291,7 @@ public: @endcode @return The result of lexicographically comparing `s` and the string. - + @param t The string to compare. */ template BOOST_STATIC_STRING_CPP14_CONSTEXPR void - swap(basic_static_string& s); + swap(basic_static_string& s); /** Replace a part of the string. @@ -3594,7 +3594,7 @@ public: @note The replacement is done unchecked when the capacity of `str` differs from that of the string the function is called on. - + All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated. @@ -3645,7 +3645,7 @@ public: @note The replacement is done unchecked when the capacity of `str` differs from that of the string the function is called on. - + All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated. @@ -3905,7 +3905,7 @@ public: @note The replacement is done unchecked when the capacity of `str` differs from that of the string the function is called on. - + All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated. @@ -4126,7 +4126,7 @@ public: @par Constraints - `InputIterator` satisfies __InputIterator__ and does not + `InputIterator` satisfies __InputIterator__ and does not satisfy __ForwardIterator__. @return `*this` @@ -4147,9 +4147,9 @@ public: #else typename std::enable_if< detail::is_input_iterator< - InputIterator>::value && + InputIterator>::value && !detail::is_forward_iterator< - InputIterator>::value, + InputIterator>::value, basic_static_string&>::type #endif replace( @@ -4256,9 +4256,9 @@ public: const string_view_type sv = t; return find(sv.data(), pos, sv.size()); } - + /** Find the first occurrence of a string within the string. - + Finds the first occurrence of `str` within the string starting at the index `pos`. @@ -4266,9 +4266,9 @@ public: Linear. - @return The lowest index `idx` greater than or equal to `pos` - where each element of `str` is equal to that of - `{begin() + idx, begin() + idx + str.size())` + @return The lowest index `idx` greater than or equal to `pos` + where each element of `str` is equal to that of + `{begin() + idx, begin() + idx + str.size())` if one exists, and @ref npos otherwise. @param str The string to search for. @@ -4308,7 +4308,7 @@ public: BOOST_STATIC_STRING_CPP14_CONSTEXPR size_type find( - const_pointer s, + const_pointer s, size_type pos, size_type n) const noexcept; @@ -4403,7 +4403,7 @@ public: size_type rfind( const T& t, - size_type pos = npos) const + size_type pos = npos) const noexcept(detail::is_nothrow_convertible::value) { const string_view_type sv = t; @@ -4460,7 +4460,7 @@ public: BOOST_STATIC_STRING_CPP14_CONSTEXPR size_type rfind( - const_pointer s, + const_pointer s, size_type pos, size_type n) const noexcept; @@ -4700,7 +4700,7 @@ public: const string_view_type sv = t; return find_last_of(sv.data(), pos, sv.size()); } - + /** Find the last occurrence of any of the characters within the string. Finds the last occurrence of any of the characters within `str` within the @@ -4890,7 +4890,7 @@ public: size_type find_first_not_of( const_pointer s, - size_type pos, + size_type pos, size_type n) const noexcept; /** Find the first occurrence of any of the characters not within the string. @@ -5087,24 +5087,24 @@ public: } /** Return whether the string begins with a string. - + Returns `true` if the string begins with `s`, and `false` otherwise. - + @par Complexity - + Linear. - + @param s The string view to check for. */ BOOST_STATIC_STRING_CPP14_CONSTEXPR - bool + bool starts_with( string_view_type s) const noexcept { const size_type len = s.size(); return size() >= len && !traits_type::compare(data(), s.data(), len); } - + /** Return whether the string begins with a character. Returns `true` if the string begins with `c`, and `false` otherwise. @@ -5116,13 +5116,13 @@ public: @param c The character to check for. */ BOOST_STATIC_STRING_CPP14_CONSTEXPR - bool + bool starts_with( value_type c) const noexcept { return !empty() && traits_type::eq(front(), c); } - + /** Return whether the string begins with a string. Returns `true` if the string begins with the string @@ -5130,20 +5130,20 @@ public: and `false` otherwise. @par Complexity - + Linear. - + @param s The string to check for. */ BOOST_STATIC_STRING_CPP14_CONSTEXPR - bool + bool starts_with( const_pointer s) const noexcept { const size_type len = traits_type::length(s); return size() >= len && !traits_type::compare(data(), s, len); } - + /** Return whether the string ends with a string. Returns `true` if the string ends with `s`, and `false` otherwise. @@ -5155,14 +5155,14 @@ public: @param s The string view to check for. */ BOOST_STATIC_STRING_CPP14_CONSTEXPR - bool + bool ends_with( string_view_type s) const noexcept { const size_type len = s.size(); return size() >= len && !traits_type::compare(data() + (size() - len), s.data(), len); } - + /** Return whether the string ends with a character. Returns `true` if the string ends with `c`, and `false` otherwise. @@ -5180,7 +5180,7 @@ public: { return !empty() && traits_type::eq(back(), c); } - + /** Return whether the string ends with a string. Returns `true` if the string ends with the string @@ -5194,7 +5194,7 @@ public: @param s The string to check for. */ BOOST_STATIC_STRING_CPP14_CONSTEXPR - bool + bool ends_with( const_pointer s) const noexcept { @@ -5237,7 +5237,7 @@ private: size_type read_back( bool overwrite_null, - InputIterator first, + InputIterator first, InputIterator last); BOOST_STATIC_STRING_CPP14_CONSTEXPR @@ -5275,7 +5275,7 @@ private: insert_unchecked(data() + index, s, count); return *this; } - + BOOST_STATIC_STRING_CPP14_CONSTEXPR iterator insert_unchecked( @@ -5677,9 +5677,9 @@ swap( template inline -std::basic_ostream& +std::basic_ostream& operator<<( - std::basic_ostream& os, + std::basic_ostream& os, const basic_static_string& s) { return os << basic_string_view(s.data(), s.size()); @@ -5697,10 +5697,10 @@ operator<<( // Unsigned overloads have a + 1, for the missing digit. // Floating point overloads have a + 4, for the sign -// of the integral part, sign of the exponent, the 'e', +// of the integral part, sign of the exponent, the 'e', // and the decimal. -/// Converts `value` to a `static_string` +/// Converts `value` to a `static_string` static_string::digits10 + 2> inline to_static_string(int value) noexcept @@ -5709,7 +5709,7 @@ to_static_string(int value) noexcept std::numeric_limits::digits10 + 2>(value); } -/// Converts `value` to a `static_string` +/// Converts `value` to a `static_string` static_string::digits10 + 2> inline to_static_string(long value) noexcept @@ -5718,7 +5718,7 @@ to_static_string(long value) noexcept std::numeric_limits::digits10 + 2>(value); } -/// Converts `value` to a `static_string` +/// Converts `value` to a `static_string` static_string::digits10 + 2> inline to_static_string(long long value) noexcept @@ -5727,7 +5727,7 @@ to_static_string(long long value) noexcept std::numeric_limits::digits10 + 2>(value); } -/// Converts `value` to a `static_string` +/// Converts `value` to a `static_string` static_string::digits10 + 1> inline to_static_string(unsigned int value) noexcept @@ -5736,7 +5736,7 @@ to_static_string(unsigned int value) noexcept std::numeric_limits::digits10 + 1>(value); } -/// Converts `value` to a `static_string` +/// Converts `value` to a `static_string` static_string::digits10 + 1> inline to_static_string(unsigned long value) noexcept @@ -5745,7 +5745,7 @@ to_static_string(unsigned long value) noexcept std::numeric_limits::digits10 + 1>(value); } -/// Converts `value` to a `static_string` +/// Converts `value` to a `static_string` static_string::digits10 + 1> inline to_static_string(unsigned long long value) noexcept @@ -5754,7 +5754,7 @@ to_static_string(unsigned long long value) noexcept std::numeric_limits::digits10 + 1>(value); } -/// Converts `value` to a `static_string` +/// Converts `value` to a `static_string` static_string::max_digits10 + 4> inline to_static_string(float value) noexcept @@ -5763,7 +5763,7 @@ to_static_string(float value) noexcept std::numeric_limits::max_digits10 + 4>(value); } -/// Converts `value` to a `static_string` +/// Converts `value` to a `static_string` static_string::max_digits10 + 4> inline to_static_string(double value) noexcept @@ -5772,7 +5772,7 @@ to_static_string(double value) noexcept std::numeric_limits::max_digits10 + 4>(value); } -/// Converts `value` to a `static_string` +/// Converts `value` to a `static_string` static_string::max_digits10 + 4> inline to_static_string(long double value) noexcept @@ -5781,7 +5781,7 @@ to_static_string(long double value) noexcept std::numeric_limits::max_digits10 + 4>(value); } -/// Converts `value` to a `static_wstring` +/// Converts `value` to a `static_wstring` static_wstring::digits10 + 2> inline to_static_wstring(int value) noexcept @@ -5790,7 +5790,7 @@ to_static_wstring(int value) noexcept std::numeric_limits::digits10 + 2>(value); } -/// Converts `value` to a `static_wstring` +/// Converts `value` to a `static_wstring` static_wstring::digits10 + 2> inline to_static_wstring(long value) noexcept @@ -5799,7 +5799,7 @@ to_static_wstring(long value) noexcept std::numeric_limits::digits10 + 2>(value); } -/// Converts `value` to a `static_wstring` +/// Converts `value` to a `static_wstring` static_wstring::digits10 + 2> inline to_static_wstring(long long value) noexcept @@ -5808,7 +5808,7 @@ to_static_wstring(long long value) noexcept std::numeric_limits::digits10 + 2>(value); } -/// Converts `value` to a `static_wstring` +/// Converts `value` to a `static_wstring` static_wstring::digits10 + 1> inline to_static_wstring(unsigned int value) noexcept @@ -5817,7 +5817,7 @@ to_static_wstring(unsigned int value) noexcept std::numeric_limits::digits10 + 1>(value); } -/// Converts `value` to a `static_wstring` +/// Converts `value` to a `static_wstring` static_wstring::digits10 + 1> inline to_static_wstring(unsigned long value) noexcept @@ -5826,7 +5826,7 @@ to_static_wstring(unsigned long value) noexcept std::numeric_limits::digits10 + 1>(value); } -/// Converts `value` to a `static_wstring` +/// Converts `value` to a `static_wstring` static_wstring::digits10 + 1> inline to_static_wstring(unsigned long long value) noexcept @@ -5835,7 +5835,7 @@ to_static_wstring(unsigned long long value) noexcept std::numeric_limits::digits10 + 1>(value); } -/// Converts `value` to a `static_wstring` +/// Converts `value` to a `static_wstring` static_wstring::max_digits10 + 4> inline to_static_wstring(float value) noexcept @@ -5844,7 +5844,7 @@ to_static_wstring(float value) noexcept std::numeric_limits::max_digits10 + 4>(value); } -/// Converts `value` to a `static_wstring` +/// Converts `value` to a `static_wstring` static_wstring::max_digits10 + 4> inline to_static_wstring(double value) noexcept @@ -5853,7 +5853,7 @@ to_static_wstring(double value) noexcept std::numeric_limits::max_digits10 + 4>(value); } -/// Converts `value` to a `static_wstring` +/// Converts `value` to a `static_wstring` static_wstring::max_digits10 + 4> inline to_static_wstring(long double value) noexcept @@ -5870,7 +5870,7 @@ to_static_wstring(long double value) noexcept #ifdef BOOST_STATIC_STRING_USE_DEDUCT template -basic_static_string(const CharT(&)[N]) -> +basic_static_string(const CharT(&)[N]) -> basic_static_string>; #endif @@ -5882,10 +5882,10 @@ basic_static_string(const CharT(&)[N]) -> #ifndef BOOST_STATIC_STRING_STANDALONE /// hash_value overload for Boost.Container_Hash -template -std::size_t +std::size_t hash_value( const basic_static_string& str) { @@ -5918,7 +5918,7 @@ struct hash< #endif > { - std::size_t + std::size_t operator()( const boost::static_strings::basic_static_string& str) const noexcept { @@ -6083,7 +6083,7 @@ insert( InputIterator last) -> typename std::enable_if< detail::is_input_iterator< - InputIterator>::value && + InputIterator>::value && !detail::is_forward_iterator< InputIterator>::value, iterator>::type { @@ -6230,7 +6230,7 @@ replace( const auto curr_data = data(); const std::size_t n1 = i2 - i1; if (n > max_size() || curr_size - n1 >= max_size() - n) - detail::throw_exception( + detail::throw_exception( "replaced string exceeds max_size()"); const auto pos = i1 - curr_data; traits_type::move(&curr_data[pos + n], i2, (end() - i2) + 1); @@ -6314,7 +6314,7 @@ replace( detail::is_input_iterator< InputIterator>::value && !detail::is_forward_iterator< - InputIterator>::value, + InputIterator>::value, basic_static_string&>::type { const auto curr_size = size(); @@ -6322,7 +6322,7 @@ replace( const std::size_t n1 = detail::distance(i1, i2); const std::size_t n2 = read_back(false, j1, j2); const std::size_t pos = i1 - curr_data; - // Rotate to the correct order. [i2, end] will now start with the replaced string, + // Rotate to the correct order. [i2, end] will now start with the replaced string, // continue to the existing string not being replaced, and end with a null terminator std::rotate(&curr_data[pos], &curr_data[curr_size + 1], &curr_data[curr_size + n2 + 1]); // Move everything from the end of the splice point to the end of the rotated string to @@ -6459,7 +6459,7 @@ basic_static_string:: read_back( bool overwrite_null, InputIterator first, - InputIterator last) -> + InputIterator last) -> size_type { const auto curr_data = data(); diff --git a/test/constexpr_tests.hpp b/test/constexpr_tests.hpp index 8c7345f..af6547f 100644 --- a/test/constexpr_tests.hpp +++ b/test/constexpr_tests.hpp @@ -41,14 +41,14 @@ struct cxper_char_traits *(dest++) = *(src++); return temp; } - static constexpr char_type* copy(char_type* dest, const char_type* src, std::size_t n) - { + static constexpr char_type* copy(char_type* dest, const char_type* src, std::size_t n) + { const auto temp = dest; while (n--) *(dest++) = *(src++); return temp; } - static constexpr char_type* assign(char_type* dest, std::size_t n, char_type ch) + static constexpr char_type* assign(char_type* dest, std::size_t n, char_type ch) { const auto temp = dest; while (n--) @@ -62,8 +62,8 @@ using cxper_char_traits = std::char_traits; using cstatic_string = basic_static_string<50, char, cxper_char_traits>; inline -constexpr -bool +constexpr +bool testConstantEvaluation() { #ifdef BOOST_STATIC_STRING_CPP20 @@ -421,7 +421,7 @@ testConstantEvaluation() // ends_with a.ends_with('a'); a.ends_with("a"); - + return true; #elif defined(BOOST_STATIC_STRING_CPP14) // c++14 constexpr tests @@ -521,17 +521,17 @@ testConstantEvaluation() a.compare("a"); a.compare(0, 1, "a"); a.compare(0, 1, "a", 1); - + // substr // in gcc 5, a constexpr non-static member function returning the class // is a member of causes an ICE #ifndef BOOST_STATIC_STRING_GCC5_BAD_CONSTEXPR a.substr(0, 1); #endif - + // subview a.subview(0); - + // copy char k[20]{}; a.copy(k, 1, 0); @@ -596,9 +596,9 @@ testConstantEvaluation() return true; #elif defined(BOOST_STATIC_STRING_CPP11) // c++11 constexpr tests - return (cstatic_string().size() + - cstatic_string().length() + - cstatic_string().max_size() + + return (cstatic_string().size() + + cstatic_string().length() + + cstatic_string().max_size() + cstatic_string().capacity()) != 0 && cstatic_string().empty(); #endif diff --git a/test/static_string.cpp b/test/static_string.cpp index 695bf39..a23f25d 100644 --- a/test/static_string.cpp +++ b/test/static_string.cpp @@ -24,7 +24,7 @@ namespace boost { namespace static_strings { template class basic_static_string<420, char>; - + using string_view = basic_string_view>; template @@ -110,7 +110,7 @@ testA(S s, const typename S::value_type* str, typename S::size_type n, S expecte return s.append(str, n) == expected; } -int +int sign(int x) { if (x == 0) @@ -216,7 +216,7 @@ testR(S s, typename S::size_type pos, typename S::size_type n1, const typename S // this is a precondition violation for the const_iterator overload return s.replace(pos, n1, str, n2) == expected; else - return s.replace(pos, n1, str, n2) == expected && + return s.replace(pos, n1, str, n2) == expected && s0.replace(s0.begin() + pos, s0.begin() + pos + n1, str, str + n2) == expected; } else @@ -399,7 +399,7 @@ testAssignment() BOOST_TEST(static_string<3>{}.assign("abc", 3) == "abc"); BOOST_TEST(static_string<3>{"*"}.assign("abc", 3) == "abc"); BOOST_TEST_THROWS(static_string<1>{}.assign("abc", 3), std::length_error); - + // assign(CharT const* s) BOOST_TEST(static_string<3>{}.assign("abc") == "abc"); BOOST_TEST(static_string<3>{"*"}.assign("abc") == "abc"); @@ -413,7 +413,7 @@ testAssignment() BOOST_TEST(static_string<4>{"*"}.assign(cs.begin(), cs.end()) == "abcd"); BOOST_TEST_THROWS(static_string<2>{"*"}.assign(cs.begin(), cs.end()), std::length_error); } - + // assign(std::initializer_list ilist) BOOST_TEST(static_string<3>{}.assign({'a', 'b', 'c'}) == "abc"); BOOST_TEST(static_string<3>{"*"}.assign({'a', 'b', 'c'}) == "abc"); @@ -451,7 +451,7 @@ testAssignment() BOOST_TEST_THROWS(static_string<2>{"**"}.assign(T{}, 6, 3), std::out_of_range); BOOST_TEST_THROWS(static_string<2>{"**"}.assign(T{}, 1, 3), std::length_error); } - + //--- { @@ -472,7 +472,7 @@ testAssignment() s3 = s1, std::length_error); } - + { static_string<3> s1; s1 = "123"; @@ -686,7 +686,7 @@ testElements() BOOST_TEST(static_string<3>{"abc"}.at(2) == 'c'); BOOST_TEST_THROWS(static_string<3>{""}.at(0), std::out_of_range); BOOST_TEST_THROWS(static_string<3>{"abc"}.at(4), std::out_of_range); - + // at(size_type pos) const BOOST_TEST(cfs3{"abc"}.at(0) == 'a'); BOOST_TEST(cfs3{"abc"}.at(2) == 'c'); @@ -717,7 +717,7 @@ testElements() BOOST_TEST(static_string<3>{"a"}.back() == 'a'); BOOST_TEST(static_string<3>{"abc"}.back() == 'c'); - // back() const + // back() const BOOST_TEST(cfs3{"a"}.back() == 'a'); BOOST_TEST(cfs3{"abc"}.back() == 'c'); @@ -924,7 +924,7 @@ testInsert() BOOST_TEST(static_string<4>{"ad"}.insert(1, "bcd", 2) == "abcd"); BOOST_TEST_THROWS(static_string<4>{"abc"}.insert(4, "*"), std::out_of_range); BOOST_TEST_THROWS(static_string<3>{"abc"}.insert(1, "*"), std::length_error); - + // insert(size_type index, string_view_type sv) BOOST_TEST(static_string<3>{"ac"}.insert(1, sv{"b"}) == "abc"); BOOST_TEST_THROWS(static_string<4>{"abc"}.insert(4, sv{"*"}), std::out_of_range); @@ -1639,7 +1639,7 @@ testInsert() BOOST_TEST(testI(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 20, S("can't happen"))); } -// done +// done static void testErase() @@ -3754,7 +3754,7 @@ testToStaticString() BOOST_TEST(testTS(std::numeric_limits::max())); BOOST_TEST(testTS(std::numeric_limits::min())); BOOST_TEST(testTS(std::numeric_limits::min())); - + // these tests technically are not portable, but they will work // 99% of the time. { @@ -4136,7 +4136,7 @@ testFind() BOOST_TEST(fs1.rfind(cs1, 0) == 0); BOOST_TEST(fs1.rfind(cs2, 0) == S::npos); - + BOOST_TEST(fs1.rfind(cs2, 0, 2) == S::npos); BOOST_TEST(fs1.rfind(cs1, 4) == 0); @@ -5114,7 +5114,7 @@ testFind() - + // find_first_not_of const char* cs3 = "12456"; @@ -5963,7 +5963,7 @@ testReplace() std::stringstream a("defghi"); static_string<30> b = "abcabcdefjklmnop"; BOOST_TEST(b.replace(b.begin() + 3, b.begin() + 9, - std::istream_iterator(a), + std::istream_iterator(a), std::istream_iterator()) == "abcdefghijklmnop"); } @@ -6176,7 +6176,7 @@ testReplace() BOOST_TEST(testR(S("abcde"), 5, 1, 5, '2', S("abcde22222"))); BOOST_TEST(testR(S("abcde"), 5, 1, 10, '2', S("abcde2222222222"))); BOOST_TEST(testR(S("abcde"), 5, 1, 20, '2', S("abcde22222222222222222222"))); - + BOOST_TEST(testR(S("abcde"), 0, 4, "12345", 4, S("1234e"))); BOOST_TEST(testR(S("abcde"), 0, 4, "12345", 5, S("12345e"))); BOOST_TEST(testR(S("abcde"), 0, 4, "1234567890", 0, S("e"))); @@ -7205,13 +7205,13 @@ runTests() static_cast(cxper); testConstruct(); - + testAssignment(); - + testElements(); testIterators(); - + testCapacity(); testClear();