2019-12-16 12:23:46 -05:00
|
|
|
//
|
|
|
|
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
2020-02-01 13:51:40 -05:00
|
|
|
// Copyright (c) 2019-2020 Krystian Stasiowski (sdkrystian at gmail dot com)
|
2019-12-16 12:23:46 -05:00
|
|
|
//
|
|
|
|
// 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)
|
|
|
|
//
|
|
|
|
// Official repository: https://github.com/boostorg/static_string
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef BOOST_STATIC_STRING_STATIC_STRING_HPP
|
|
|
|
#define BOOST_STATIC_STRING_STATIC_STRING_HPP
|
|
|
|
|
|
|
|
#include <boost/static_string/config.hpp>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <cstdint>
|
2020-02-01 16:47:19 -05:00
|
|
|
#include <cstdio>
|
2020-02-01 17:29:57 -05:00
|
|
|
#include <cwchar>
|
2020-02-01 16:47:19 -05:00
|
|
|
#include <functional>
|
2019-12-16 12:23:46 -05:00
|
|
|
#include <initializer_list>
|
|
|
|
#include <iosfwd>
|
|
|
|
#include <type_traits>
|
|
|
|
|
|
|
|
namespace boost {
|
|
|
|
namespace static_string {
|
|
|
|
|
2020-02-01 16:30:23 -05:00
|
|
|
template<std::size_t, typename, typename>
|
|
|
|
class basic_static_string;
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Aliases
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
template<std::size_t N>
|
2020-02-14 16:24:44 -05:00
|
|
|
using static_string =
|
|
|
|
basic_static_string<N, char, std::char_traits<char>>;
|
2020-02-01 16:30:23 -05:00
|
|
|
|
|
|
|
template<std::size_t N>
|
2020-02-14 16:24:44 -05:00
|
|
|
using static_wstring =
|
|
|
|
basic_static_string<N, wchar_t, std::char_traits<wchar_t>>;
|
2020-02-01 16:30:23 -05:00
|
|
|
|
|
|
|
template<std::size_t N>
|
2020-02-14 16:24:44 -05:00
|
|
|
using static_u16string =
|
|
|
|
basic_static_string<N, char16_t, std::char_traits<char16_t>>;
|
2020-02-01 16:30:23 -05:00
|
|
|
|
|
|
|
template<std::size_t N>
|
2020-02-14 16:24:44 -05:00
|
|
|
using static_u32string =
|
|
|
|
basic_static_string<N, char32_t, std::char_traits<char32_t>>;
|
2020-02-01 16:30:23 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Detail
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
namespace detail {
|
|
|
|
|
|
|
|
// Find the smallest width integral type that can hold a value as large as N (Glen Fernandes)
|
|
|
|
template<std::size_t N>
|
|
|
|
using smallest_width =
|
2020-02-14 16:24:44 -05:00
|
|
|
typename std::conditional<(N <= (std::numeric_limits<unsigned char>::max)()), unsigned char,
|
|
|
|
typename std::conditional<(N <= (std::numeric_limits<unsigned short>::max)()), unsigned short,
|
|
|
|
typename std::conditional<(N <= (std::numeric_limits<unsigned int>::max)()), unsigned int,
|
|
|
|
typename std::conditional<(N <= (std::numeric_limits<unsigned long>::max)()), unsigned long,
|
|
|
|
typename std::conditional<(N <= (std::numeric_limits<unsigned long long>::max)()), unsigned long long,
|
|
|
|
void>::type>::type>::type>::type>::type;
|
2020-02-01 16:30:23 -05:00
|
|
|
|
|
|
|
// std::is_nothrow_convertible is C++20
|
|
|
|
template<typename To>
|
|
|
|
void is_nothrow_convertible_helper(To) noexcept;
|
|
|
|
|
|
|
|
// MSVC is unable to parse this as a single expression, so a helper is needed
|
|
|
|
template<typename From, typename To, typename =
|
2020-02-14 16:24:44 -05:00
|
|
|
decltype(is_nothrow_convertible_helper<To>(std::declval<From>()))>
|
2020-02-01 16:30:23 -05:00
|
|
|
struct is_nothrow_convertible_msvc_helper
|
|
|
|
{
|
|
|
|
static const bool value =
|
2020-02-14 16:24:44 -05:00
|
|
|
noexcept(is_nothrow_convertible_helper<To>(std::declval<From>()));
|
2020-02-01 16:30:23 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
template<typename From, typename To, typename = void>
|
|
|
|
struct is_nothrow_convertible
|
2020-02-14 16:24:44 -05:00
|
|
|
: std::false_type { };
|
2020-02-01 16:30:23 -05:00
|
|
|
|
|
|
|
template<typename From, typename To>
|
|
|
|
struct is_nothrow_convertible<From, To, typename std::enable_if<
|
2020-02-14 16:24:44 -05:00
|
|
|
is_nothrow_convertible_msvc_helper<From, To>::value>::type>
|
|
|
|
: std::true_type { };
|
2020-02-01 16:30:23 -05:00
|
|
|
|
|
|
|
// GCC 4.8, 4.9 workaround for void_t to make the defining-type-id dependant
|
|
|
|
template<typename...>
|
|
|
|
struct void_t_helper
|
|
|
|
{
|
|
|
|
using type = void;
|
|
|
|
};
|
|
|
|
|
|
|
|
// void_t for c++11
|
|
|
|
template<typename... Ts>
|
|
|
|
using void_t = typename void_t_helper<Ts...>::type;
|
|
|
|
|
2020-02-21 19:00:54 -05:00
|
|
|
// Check if a type can be used for templated
|
|
|
|
// overloads string_view_type
|
|
|
|
|
|
|
|
template<typename T, typename CharT, typename Traits, typename = void>
|
|
|
|
struct enable_if_viewable { };
|
|
|
|
|
|
|
|
template<typename T, typename CharT, typename Traits>
|
|
|
|
struct enable_if_viewable<T, CharT, Traits,
|
|
|
|
typename std::enable_if<
|
|
|
|
std::is_convertible<const T&, basic_string_view<CharT, Traits>>::value &&
|
|
|
|
!std::is_convertible<const T&, const CharT*>::value>::type>
|
|
|
|
{
|
|
|
|
using type = void;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T, typename CharT, typename Traits>
|
|
|
|
using enable_if_viewable_t = typename enable_if_viewable<T, CharT, Traits>::type;
|
|
|
|
|
2020-02-01 16:30:23 -05:00
|
|
|
// Simplified check for if a type is an iterator
|
2020-02-21 19:30:34 -05:00
|
|
|
template<typename T, typename = void>
|
2020-02-01 16:30:23 -05:00
|
|
|
struct is_iterator : std::false_type { };
|
|
|
|
|
2020-02-21 19:30:34 -05:00
|
|
|
template<typename T>
|
2020-02-01 16:30:23 -05:00
|
|
|
struct is_iterator<T,
|
2020-02-14 16:24:44 -05:00
|
|
|
typename std::enable_if<std::is_class<T>::value,
|
|
|
|
void_t<typename T::iterator_category>>::type>
|
|
|
|
: std::true_type { };
|
2020-02-01 16:30:23 -05:00
|
|
|
|
2020-02-21 19:30:34 -05:00
|
|
|
template<typename T>
|
2020-02-01 16:30:23 -05:00
|
|
|
struct is_iterator<T*, void>
|
2020-02-14 16:24:44 -05:00
|
|
|
: std::true_type { };
|
2020-02-01 16:30:23 -05:00
|
|
|
|
2020-02-21 19:30:34 -05:00
|
|
|
template<typename T, typename = void>
|
2020-02-01 16:30:23 -05:00
|
|
|
struct is_input_iterator : std::false_type { };
|
|
|
|
|
2020-02-21 19:30:34 -05:00
|
|
|
template<typename T>
|
2020-02-01 16:30:23 -05:00
|
|
|
struct is_input_iterator<T, typename std::enable_if<is_iterator<T>::value &&
|
2020-02-14 16:24:44 -05:00
|
|
|
std::is_convertible<typename std::iterator_traits<T>::iterator_category,
|
|
|
|
std::input_iterator_tag>::value>::type>
|
|
|
|
: std::true_type { };
|
2020-02-01 16:30:23 -05:00
|
|
|
|
2020-02-21 19:30:34 -05:00
|
|
|
template<typename T, typename = void>
|
2020-02-01 16:30:23 -05:00
|
|
|
struct is_forward_iterator : std::false_type { };
|
|
|
|
|
2020-02-21 19:30:34 -05:00
|
|
|
template<typename T>
|
2020-02-01 16:30:23 -05:00
|
|
|
struct is_forward_iterator<T, typename std::enable_if<is_iterator<T>::value &&
|
2020-02-14 16:24:44 -05:00
|
|
|
std::is_convertible<typename std::iterator_traits<T>::iterator_category,
|
|
|
|
std::forward_iterator_tag>::value>::type>
|
|
|
|
: std::true_type { };
|
2020-02-01 16:30:23 -05:00
|
|
|
|
|
|
|
template<typename T, typename = void>
|
|
|
|
struct is_subtractable
|
2020-02-14 16:24:44 -05:00
|
|
|
: std::false_type { };
|
2020-02-01 16:30:23 -05:00
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
struct is_subtractable<T, void_t<decltype(std::declval<T&>() - std::declval<T&>())>>
|
2020-02-14 16:24:44 -05:00
|
|
|
: std::true_type { };
|
2020-02-01 16:30:23 -05:00
|
|
|
|
|
|
|
// constexpr distance for c++14
|
2020-02-14 16:24:44 -05:00
|
|
|
template<
|
|
|
|
typename ForwardIt,
|
|
|
|
typename std::enable_if<!is_subtractable<ForwardIt>::value>::type* = nullptr>
|
2020-02-01 16:30:23 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2020-02-14 13:50:07 -05:00
|
|
|
std::size_t
|
|
|
|
distance(ForwardIt first, ForwardIt last)
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
std::size_t dist = 0;
|
|
|
|
for (; first != last; ++first, ++dist);
|
|
|
|
return dist;
|
|
|
|
}
|
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
template<
|
|
|
|
typename RandomIt,
|
|
|
|
typename std::enable_if<is_subtractable<RandomIt>::value>::type* = nullptr>
|
2020-02-01 16:30:23 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2020-02-14 13:50:07 -05:00
|
|
|
std::size_t
|
2020-02-01 16:30:23 -05:00
|
|
|
distance(RandomIt first, RandomIt last)
|
|
|
|
{
|
|
|
|
return last - first;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy using traits, respecting iterator rules
|
|
|
|
template<typename Traits, typename InputIt, typename CharT>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
void
|
2020-02-14 16:24:44 -05:00
|
|
|
copy_with_traits(
|
|
|
|
InputIt first,
|
|
|
|
InputIt last,
|
|
|
|
CharT* out)
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
for (; first != last; ++first, ++out)
|
|
|
|
Traits::assign(*out, *first);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Optimization for using the smallest possible type
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
2020-02-07 13:50:14 -05:00
|
|
|
class static_string_base
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
2020-02-14 13:50:07 -05:00
|
|
|
private:
|
|
|
|
using size_type = smallest_width<N>;
|
2020-02-14 17:21:54 -05:00
|
|
|
using value_type = typename Traits::char_type;
|
|
|
|
using pointer = value_type*;
|
|
|
|
using const_pointer = const value_type*;
|
2020-02-01 16:30:23 -05:00
|
|
|
public:
|
|
|
|
BOOST_STATIC_STRING_CPP11_CONSTEXPR
|
2020-02-07 13:50:14 -05:00
|
|
|
static_string_base() noexcept { };
|
2020-02-01 16:30:23 -05:00
|
|
|
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2020-02-14 17:21:54 -05:00
|
|
|
pointer
|
2020-02-01 16:30:23 -05:00
|
|
|
data_impl() noexcept
|
|
|
|
{
|
|
|
|
return data_;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer
|
2020-02-01 16:30:23 -05:00
|
|
|
data_impl() const noexcept
|
|
|
|
{
|
|
|
|
return data_;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_STATIC_STRING_CPP11_CONSTEXPR
|
|
|
|
std::size_t
|
|
|
|
size_impl() const noexcept
|
|
|
|
{
|
|
|
|
return size_;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
std::size_t
|
|
|
|
set_size(std::size_t n) noexcept
|
|
|
|
{
|
2020-02-14 13:50:07 -05:00
|
|
|
// Functions that set size will throw
|
|
|
|
// if the new size would exceed max_size()
|
|
|
|
// therefore we can guarantee that this will
|
|
|
|
// not lose data.
|
|
|
|
return size_ = size_type(n);
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
void
|
|
|
|
term_impl() noexcept
|
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
Traits::assign(data_[size_], value_type());
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
|
|
|
|
2020-02-22 15:43:52 -05:00
|
|
|
size_type size_ = 0;
|
2020-02-01 21:19:29 -05:00
|
|
|
#ifdef BOOST_STATIC_STRING_CPP20
|
2020-02-14 17:21:54 -05:00
|
|
|
value_type data_[N + 1];
|
2020-02-01 16:30:23 -05:00
|
|
|
#else
|
2020-02-14 17:21:54 -05:00
|
|
|
value_type data_[N + 1]{};
|
2020-02-01 16:30:23 -05:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
// Optimization for when the size is 0
|
|
|
|
template<typename CharT, typename Traits>
|
2020-02-07 13:50:14 -05:00
|
|
|
class static_string_base<0, CharT, Traits>
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
private:
|
|
|
|
using value_type = typename Traits::char_type;
|
|
|
|
using pointer = value_type*;
|
2020-02-01 16:30:23 -05:00
|
|
|
public:
|
|
|
|
BOOST_STATIC_STRING_CPP11_CONSTEXPR
|
2020-02-07 13:50:14 -05:00
|
|
|
static_string_base() noexcept { }
|
2020-02-01 16:30:23 -05:00
|
|
|
|
|
|
|
// Modifying the null terminator is UB
|
|
|
|
BOOST_STATIC_STRING_CPP11_CONSTEXPR
|
2020-02-14 17:21:54 -05:00
|
|
|
pointer
|
2020-02-01 16:30:23 -05:00
|
|
|
data_impl() const noexcept
|
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
return const_cast<pointer>(&null_);
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_STATIC_STRING_CPP11_CONSTEXPR
|
|
|
|
std::size_t
|
|
|
|
size_impl() const noexcept
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_STATIC_STRING_CPP11_CONSTEXPR
|
|
|
|
std::size_t
|
|
|
|
set_size(std::size_t) noexcept
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
void
|
|
|
|
term_impl() noexcept { }
|
|
|
|
|
|
|
|
private:
|
2020-02-14 17:21:54 -05:00
|
|
|
static constexpr const value_type null_{};
|
2020-02-01 16:30:23 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
template<typename CharT, typename Traits>
|
2020-02-14 17:21:54 -05:00
|
|
|
constexpr
|
|
|
|
const
|
|
|
|
typename static_string_base<0, CharT, Traits>::value_type
|
|
|
|
static_string_base<0, CharT, Traits>::
|
|
|
|
null_;
|
2020-02-01 16:30:23 -05:00
|
|
|
|
|
|
|
template<typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
inline
|
|
|
|
int
|
|
|
|
lexicographical_compare(
|
2020-02-14 17:21:54 -05:00
|
|
|
const CharT* s1,
|
2020-02-14 16:24:44 -05:00
|
|
|
std::size_t n1,
|
2020-02-14 17:21:54 -05:00
|
|
|
const CharT* s2,
|
2020-02-14 16:24:44 -05:00
|
|
|
std::size_t n2) noexcept
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
if(n1 < n2)
|
|
|
|
return Traits::compare(
|
|
|
|
s1, s2, n1) <= 0 ? -1 : 1;
|
|
|
|
if(n1 > n2)
|
|
|
|
return Traits::compare(
|
|
|
|
s1, s2, n2) >= 0 ? 1 : -1;
|
|
|
|
return Traits::compare(s1, s2, n1);
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Traits, typename Integer>
|
|
|
|
inline
|
|
|
|
char*
|
|
|
|
integer_to_string(
|
2020-02-14 16:24:44 -05:00
|
|
|
char* str_end,
|
|
|
|
Integer value,
|
|
|
|
std::true_type) noexcept
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
if (value == 0)
|
|
|
|
{
|
|
|
|
Traits::assign(*--str_end, '0');
|
|
|
|
return str_end;
|
|
|
|
}
|
|
|
|
if (value < 0)
|
|
|
|
{
|
2020-02-22 15:43:52 -05:00
|
|
|
const bool is_min = value == std::numeric_limits<Integer>::min();
|
|
|
|
// negation of a min value cannot be represented
|
|
|
|
if (is_min)
|
|
|
|
value = std::numeric_limits<Integer>::max();
|
|
|
|
else
|
|
|
|
value = -value;
|
|
|
|
const auto last_char = str_end - 1;
|
2020-02-01 16:30:23 -05:00
|
|
|
for (; value > 0; value /= 10)
|
|
|
|
Traits::assign(*--str_end, "0123456789"[value % 10]);
|
2020-02-22 15:43:52 -05:00
|
|
|
// minimum values are powers of 2, so it will
|
|
|
|
// never terminate with a 9.
|
|
|
|
if (is_min)
|
|
|
|
Traits::assign(*last_char, Traits::to_char_type(
|
|
|
|
Traits::to_int_type(*last_char) + 1));
|
2020-02-01 16:30:23 -05:00
|
|
|
Traits::assign(*--str_end, '-');
|
|
|
|
return str_end;
|
|
|
|
}
|
|
|
|
for (; value > 0; value /= 10)
|
|
|
|
Traits::assign(*--str_end, "0123456789"[value % 10]);
|
|
|
|
return str_end;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Traits, typename Integer>
|
|
|
|
inline
|
|
|
|
char*
|
|
|
|
integer_to_string(
|
2020-02-14 16:24:44 -05:00
|
|
|
char* str_end,
|
|
|
|
Integer value,
|
|
|
|
std::false_type) noexcept
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
if (value == 0)
|
|
|
|
{
|
|
|
|
Traits::assign(*--str_end, '0');
|
|
|
|
return str_end;
|
|
|
|
}
|
|
|
|
for (; value > 0; value /= 10)
|
|
|
|
Traits::assign(*--str_end, "0123456789"[value % 10]);
|
|
|
|
return str_end;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Traits, typename Integer>
|
|
|
|
inline
|
|
|
|
wchar_t*
|
|
|
|
integer_to_wstring(
|
2020-02-14 16:24:44 -05:00
|
|
|
wchar_t* str_end,
|
|
|
|
Integer value,
|
|
|
|
std::true_type) noexcept
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
if (value == 0)
|
|
|
|
{
|
|
|
|
Traits::assign(*--str_end, L'0');
|
|
|
|
return str_end;
|
|
|
|
}
|
|
|
|
if (value < 0)
|
|
|
|
{
|
2020-02-22 15:43:52 -05:00
|
|
|
const bool is_min = value == std::numeric_limits<Integer>::min();
|
|
|
|
// negation of a min value cannot be represented
|
|
|
|
if (is_min)
|
|
|
|
value = std::numeric_limits<Integer>::max();
|
|
|
|
else
|
|
|
|
value = -value;
|
|
|
|
const auto last_char = str_end - 1;
|
2020-02-01 16:30:23 -05:00
|
|
|
for (; value > 0; value /= 10)
|
|
|
|
Traits::assign(*--str_end, L"0123456789"[value % 10]);
|
2020-02-22 15:43:52 -05:00
|
|
|
// minimum values are powers of 2, so it will
|
|
|
|
// never terminate with a 9.
|
|
|
|
if (is_min)
|
|
|
|
Traits::assign(*last_char, Traits::to_char_type(
|
|
|
|
Traits::to_int_type(*last_char) + 1));
|
2020-02-01 16:30:23 -05:00
|
|
|
Traits::assign(*--str_end, L'-');
|
|
|
|
return str_end;
|
|
|
|
}
|
|
|
|
for (; value > 0; value /= 10)
|
|
|
|
Traits::assign(*--str_end, L"0123456789"[value % 10]);
|
|
|
|
return str_end;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Traits, typename Integer>
|
|
|
|
inline
|
|
|
|
wchar_t*
|
|
|
|
integer_to_wstring(
|
2020-02-14 16:24:44 -05:00
|
|
|
wchar_t* str_end,
|
|
|
|
Integer value,
|
|
|
|
std::false_type) noexcept
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
if (value == 0)
|
|
|
|
{
|
|
|
|
Traits::assign(*--str_end, L'0');
|
|
|
|
return str_end;
|
|
|
|
}
|
|
|
|
for (; value > 0; value /= 10)
|
|
|
|
Traits::assign(*--str_end, L"0123456789"[value % 10]);
|
|
|
|
return str_end;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename Integer>
|
|
|
|
inline
|
|
|
|
static_string<N>
|
|
|
|
to_static_string_int_impl(Integer value) noexcept
|
|
|
|
{
|
|
|
|
char buffer[N];
|
|
|
|
const auto digits_end = std::end(buffer);
|
|
|
|
const auto digits_begin = integer_to_string<std::char_traits<char>, Integer>(
|
|
|
|
digits_end, value, std::is_signed<Integer>{});
|
|
|
|
return static_string<N>(digits_begin, std::distance(digits_begin, digits_end));
|
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename Integer>
|
|
|
|
inline
|
|
|
|
static_wstring<N>
|
|
|
|
to_static_wstring_int_impl(Integer value) noexcept
|
|
|
|
{
|
|
|
|
wchar_t buffer[N];
|
|
|
|
const auto digits_end = std::end(buffer);
|
|
|
|
const auto digits_begin = integer_to_wstring<std::char_traits<wchar_t>, Integer>(
|
|
|
|
digits_end, value, std::is_signed<Integer>{});
|
|
|
|
return static_wstring<N>(digits_begin, std::distance(digits_begin, digits_end));
|
|
|
|
}
|
|
|
|
|
2020-02-22 15:43:52 -05:00
|
|
|
BOOST_STATIC_STRING_CPP11_CONSTEXPR
|
|
|
|
inline
|
|
|
|
std::size_t count_digits(std::size_t value)
|
|
|
|
{
|
|
|
|
return value < 10 ? 1 : count_digits(value / 10) + 1;
|
|
|
|
}
|
|
|
|
|
2020-02-02 22:35:14 -05:00
|
|
|
template<std::size_t N>
|
|
|
|
inline
|
|
|
|
static_string<N>
|
|
|
|
to_static_string_float_impl(double value) noexcept
|
|
|
|
{
|
|
|
|
// extra one needed for null terminator
|
|
|
|
char buffer[N + 1];
|
2020-02-22 15:43:52 -05:00
|
|
|
// since our buffer has a fixed size, if the number of characters
|
|
|
|
// that would be written exceeds the size of the buffer,
|
|
|
|
// we need touse scientific notation instead.
|
|
|
|
// the number is converted into the format
|
|
|
|
// [-]d.ddde(+/-)dd; the exponent will contain at least
|
|
|
|
// 2 digits, the integral part will be 1 digit, the fractional
|
|
|
|
// part will be the length of the specified precision, and 3
|
|
|
|
// characters will be needed for e, the sign of the exponent
|
|
|
|
// and the potential sign of the integral part, total of 6 chars.
|
|
|
|
// we will reserve 7 characters just in case the size of the exponent
|
|
|
|
// is 3 characters.
|
2020-02-22 17:44:57 -05:00
|
|
|
// snprintf returns the number of characters
|
|
|
|
// that would have been written
|
|
|
|
if (std::snprintf(buffer, N + 1, "%f", value) > N)
|
2020-02-22 15:43:52 -05:00
|
|
|
{
|
|
|
|
const auto period =
|
|
|
|
std::char_traits<char>::find(buffer, N, '.');
|
|
|
|
// we want at least 2 decimal places
|
|
|
|
if (!period || std::size_t(period - buffer) > N - 3)
|
|
|
|
std::snprintf(buffer, N + 1, "%.*e", int(N > 7 ? N - 7 : 0), value);
|
|
|
|
}
|
2020-02-02 22:35:14 -05:00
|
|
|
// this will not throw
|
|
|
|
return static_string<N>(buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N>
|
2020-02-01 16:30:23 -05:00
|
|
|
inline
|
|
|
|
static_string<N>
|
2020-02-02 22:35:14 -05:00
|
|
|
to_static_string_float_impl(long double value) noexcept
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
// extra one needed for null terminator
|
|
|
|
char buffer[N + 1];
|
2020-02-22 17:44:57 -05:00
|
|
|
// snprintf returns the number of characters
|
|
|
|
// that would have been written
|
|
|
|
if (std::snprintf(buffer, N + 1, "%Lf", value) > N)
|
2020-02-22 15:43:52 -05:00
|
|
|
{
|
|
|
|
const auto period =
|
|
|
|
std::char_traits<char>::find(buffer, N, '.');
|
|
|
|
// we want at least 2 decimal places
|
|
|
|
if (!period || std::size_t(period - buffer) > N - 3)
|
2020-02-22 16:45:19 -05:00
|
|
|
std::snprintf(buffer, N + 1, "%.*Le", int(N > 7 ? N - 7 : 0), value);
|
2020-02-22 15:43:52 -05:00
|
|
|
}
|
2020-02-01 16:30:23 -05:00
|
|
|
// this will not throw
|
|
|
|
return static_string<N>(buffer);
|
|
|
|
}
|
|
|
|
|
2020-02-02 22:35:14 -05:00
|
|
|
template<std::size_t N>
|
|
|
|
inline
|
|
|
|
static_wstring<N>
|
|
|
|
to_static_wstring_float_impl(double value) noexcept
|
|
|
|
{
|
|
|
|
// extra one needed for null terminator
|
|
|
|
wchar_t buffer[N + 1];
|
2020-02-22 17:44:57 -05:00
|
|
|
// swprintf returns a negative number if it can't
|
|
|
|
// fit all the characters in the buffer
|
|
|
|
if (std::swprintf(buffer, N + 1, L"%f", value) < 0)
|
2020-02-22 15:43:52 -05:00
|
|
|
{
|
|
|
|
const auto period =
|
|
|
|
std::char_traits<wchar_t>::find(buffer, N, '.');
|
|
|
|
// we want at least 2 decimal places
|
|
|
|
if (!period || std::size_t(period - buffer) > N - 3)
|
|
|
|
std::swprintf(buffer, N + 1, L"%.*e", int(N > 7 ? N - 7 : 0), value);
|
|
|
|
}
|
2020-02-02 22:35:14 -05:00
|
|
|
// this will not throw
|
|
|
|
return static_wstring<N>(buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N>
|
2020-02-01 16:30:23 -05:00
|
|
|
inline
|
|
|
|
static_wstring<N>
|
2020-02-02 22:35:14 -05:00
|
|
|
to_static_wstring_float_impl(long double value) noexcept
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
// extra one needed for null terminator
|
|
|
|
wchar_t buffer[N + 1];
|
2020-02-22 17:44:57 -05:00
|
|
|
// swprintf returns a negative number if it can't
|
|
|
|
// fit all the characters in the buffer
|
|
|
|
if (std::swprintf(buffer, N + 1, L"%Lf", value) < 0)
|
2020-02-22 15:43:52 -05:00
|
|
|
{
|
|
|
|
const auto period =
|
|
|
|
std::char_traits<wchar_t>::find(buffer, N, '.');
|
|
|
|
// we want at least 2 decimal places
|
|
|
|
if (!period || std::size_t(period - buffer) > N - 3)
|
2020-02-22 16:45:19 -05:00
|
|
|
std::swprintf(buffer, N + 1, L"%.*Le", int(N > 7 ? N - 7 : 0), value);
|
2020-02-22 15:43:52 -05:00
|
|
|
}
|
2020-02-01 16:30:23 -05:00
|
|
|
// this will not throw
|
|
|
|
return static_wstring<N>(buffer);
|
|
|
|
}
|
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
template<typename Traits, typename CharT, typename ForwardIterator>
|
2020-02-01 16:30:23 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
inline
|
|
|
|
ForwardIterator
|
|
|
|
find_not_of(
|
2020-02-14 16:24:44 -05:00
|
|
|
ForwardIterator first,
|
|
|
|
ForwardIterator last,
|
|
|
|
const CharT* str,
|
|
|
|
std::size_t n) noexcept
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
for (; first != last; ++first)
|
|
|
|
if (!Traits::find(str, n, *first))
|
|
|
|
return first;
|
|
|
|
return last;
|
|
|
|
}
|
|
|
|
|
|
|
|
// constexpr search for C++14
|
2020-02-14 16:24:44 -05:00
|
|
|
template<typename ForwardIt1, typename ForwardIt2, typename BinaryPredicate>
|
2020-02-01 16:30:23 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
inline
|
|
|
|
ForwardIt1
|
|
|
|
search(
|
2020-02-14 16:24:44 -05:00
|
|
|
ForwardIt1 first,
|
|
|
|
ForwardIt1 last,
|
|
|
|
ForwardIt2 s_first,
|
|
|
|
ForwardIt2 s_last,
|
|
|
|
BinaryPredicate p)
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
for (; ; ++first)
|
|
|
|
{
|
|
|
|
ForwardIt1 it = first;
|
|
|
|
for (ForwardIt2 s_it = s_first; ; ++it, ++s_it)
|
|
|
|
{
|
|
|
|
if (s_it == s_last)
|
|
|
|
return first;
|
|
|
|
if (it == last)
|
|
|
|
return last;
|
|
|
|
if (!p(*it, *s_it))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
template<typename InputIt, typename ForwardIt, typename BinaryPredicate>
|
2020-02-01 16:30:23 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
inline
|
|
|
|
InputIt
|
|
|
|
find_first_of(
|
2020-02-14 16:24:44 -05:00
|
|
|
InputIt first,
|
|
|
|
InputIt last,
|
|
|
|
ForwardIt s_first,
|
|
|
|
ForwardIt s_last,
|
|
|
|
BinaryPredicate p)
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
for (; first != last; ++first)
|
|
|
|
for (ForwardIt it = s_first; it != s_last; ++it)
|
|
|
|
if (p(*first, *it))
|
|
|
|
return first;
|
|
|
|
return last;
|
|
|
|
}
|
|
|
|
|
2020-02-02 11:43:17 -05:00
|
|
|
// Check if a pointer lies within the range [src_first, src_last)
|
|
|
|
// without unspecified behavior, allowing it to be used
|
|
|
|
// in a constant evaluation.
|
2020-02-01 16:30:23 -05:00
|
|
|
template<typename T>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
inline
|
|
|
|
bool
|
2020-02-06 16:48:02 -05:00
|
|
|
ptr_in_range(
|
2020-02-14 16:24:44 -05:00
|
|
|
const T* src_first,
|
|
|
|
const T* src_last,
|
|
|
|
const T* ptr)
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
2020-02-19 21:41:38 -05:00
|
|
|
#if defined(BOOST_STATIC_STRING_CPP14) && \
|
2020-02-19 22:02:41 -05:00
|
|
|
defined(BOOST_STATIC_STRING_IS_CONST_EVAL)
|
2020-02-01 21:19:29 -05:00
|
|
|
// Our second best option is to use is_constant_evaluated
|
|
|
|
// 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)
|
|
|
|
{
|
|
|
|
for (; src_first != src_last; ++src_first)
|
2020-02-02 13:36:18 -05:00
|
|
|
if (ptr == src_first)
|
2020-02-01 21:19:29 -05:00
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
2020-02-19 22:02:41 -05:00
|
|
|
// We want to make this usable in constant expressions as much as possible
|
|
|
|
// while retaining the guarentee that the comparison has a strict total ordering.
|
|
|
|
// We also want this to be fast. Since different compilers have differing levels
|
|
|
|
// of conformance, we will settle for the best option that is available.
|
|
|
|
// 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)
|
|
|
|
// If library comparison functions don't work,
|
|
|
|
// we can use try builtin comparison operators instead.
|
|
|
|
return ptr >= src_first && ptr < src_last;
|
|
|
|
#else
|
2020-02-01 21:19:29 -05:00
|
|
|
// Use the library comparison functions if we can't use
|
|
|
|
// is_constant_evaluated or if we don't need to.
|
|
|
|
return std::greater_equal<const T*>()(ptr, src_first) &&
|
2020-02-02 11:43:17 -05:00
|
|
|
std::less<const T*>()(ptr, src_last);
|
2020-02-19 22:02:41 -05:00
|
|
|
#endif
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
|
|
|
} // detail
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// static_string
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
|
2019-12-16 12:23:46 -05:00
|
|
|
/** A fixed-capacity string.
|
|
|
|
|
|
|
|
These objects behave like `std::string` except that the storage
|
|
|
|
is not dynamically allocated but rather fixed in size, and
|
|
|
|
stored in the object itself.
|
|
|
|
|
|
|
|
These strings offer performance advantages when an algorithm
|
|
|
|
can execute with a reasonable upper limit on the size of a value.
|
|
|
|
|
|
|
|
@see to_static_string
|
|
|
|
*/
|
2020-02-14 16:24:44 -05:00
|
|
|
template<std::size_t N, typename CharT,
|
|
|
|
typename Traits = std::char_traits<CharT>>
|
2019-12-16 12:23:46 -05:00
|
|
|
class basic_static_string
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
2020-02-07 13:50:14 -05:00
|
|
|
: private detail::static_string_base<N, CharT, Traits>
|
2019-12-16 12:23:46 -05:00
|
|
|
#endif
|
2019-10-27 21:01:44 -04:00
|
|
|
{
|
2019-12-16 12:23:46 -05:00
|
|
|
private:
|
2020-02-14 16:24:44 -05:00
|
|
|
template<std::size_t, class, class>
|
|
|
|
friend class basic_static_string;
|
2019-12-16 12:23:46 -05:00
|
|
|
public:
|
2020-02-14 16:24:44 -05:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Member types
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
using traits_type = Traits;
|
2020-02-14 17:21:54 -05:00
|
|
|
using value_type = typename traits_type::char_type;
|
2020-02-14 16:24:44 -05:00
|
|
|
using size_type = std::size_t;
|
|
|
|
using difference_type = std::ptrdiff_t;
|
|
|
|
using pointer = value_type*;
|
|
|
|
using reference = value_type&;
|
2020-02-14 17:21:54 -05:00
|
|
|
using const_pointer = const value_type*;
|
|
|
|
using const_reference = const value_type&;
|
2020-02-14 16:24:44 -05:00
|
|
|
using iterator = value_type*;
|
2020-02-14 17:21:54 -05:00
|
|
|
using const_iterator = const value_type*;
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
using reverse_iterator =
|
|
|
|
std::reverse_iterator<iterator>;
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
using const_reverse_iterator =
|
|
|
|
std::reverse_iterator<const_iterator>;
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// The type of `string_view_type` returned by the interface
|
|
|
|
using string_view_type =
|
2020-02-14 17:21:54 -05:00
|
|
|
basic_string_view<value_type, traits_type>;
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Constants
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Maximum size of the string excluding any null terminator
|
|
|
|
static constexpr size_type static_capacity = N;
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// A special index
|
|
|
|
static constexpr size_type npos = size_type(-1);
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Construction
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Construct a `basic_static_string`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Construct an empty string
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP11_CONSTEXPR
|
2020-02-21 11:26:27 -05:00
|
|
|
basic_static_string() noexcept
|
|
|
|
{
|
|
|
|
#ifdef BOOST_STATIC_STRING_CPP20
|
|
|
|
term();
|
|
|
|
#endif
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Construct a `basic_static_string`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Construct the string with `count` copies of character `ch`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
The behavior is undefined if `count >= npos`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string(
|
|
|
|
size_type count,
|
2020-02-21 11:26:27 -05:00
|
|
|
value_type ch)
|
|
|
|
{
|
|
|
|
assign(count, ch);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Construct a `basic_static_string`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Construct with a substring (pos, other.size()) of `other`.
|
|
|
|
*/
|
|
|
|
template<std::size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string(
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<M, CharT, Traits>& other,
|
2020-02-21 11:26:27 -05:00
|
|
|
size_type pos)
|
|
|
|
{
|
|
|
|
assign(other, pos);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Construct a `basic_static_string`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Construct with a substring (pos, count) of `other`.
|
|
|
|
*/
|
|
|
|
template<std::size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string(
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<M, CharT, Traits>& other,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos,
|
2020-02-21 11:26:27 -05:00
|
|
|
size_type count)
|
|
|
|
{
|
|
|
|
assign(other, pos, count);
|
|
|
|
}
|
2020-02-14 16:24:44 -05:00
|
|
|
|
|
|
|
/** Construct a `basic_static_string`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Construct with the first `count` characters of `s`, including nulls.
|
2019-12-16 12:23:46 -05:00
|
|
|
*/
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-21 11:26:27 -05:00
|
|
|
size_type count)
|
|
|
|
{
|
|
|
|
assign(s, count);
|
|
|
|
}
|
2020-02-14 16:24:44 -05:00
|
|
|
|
|
|
|
/** Construct a `basic_static_string`.
|
|
|
|
|
|
|
|
Construct from a null terminated string.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2020-02-14 17:21:54 -05:00
|
|
|
basic_static_string(const_pointer s);
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-21 20:01:22 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Construct a `basic_static_string`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Construct from a range of characters
|
|
|
|
*/
|
2020-02-21 19:30:34 -05:00
|
|
|
template<typename InputIterator
|
2020-01-15 16:23:12 -05:00
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
2020-02-14 16:24:44 -05:00
|
|
|
, typename std::enable_if<
|
|
|
|
detail::is_input_iterator<InputIterator>
|
|
|
|
::value>::type* = nullptr
|
2020-01-15 16:23:12 -05:00
|
|
|
#endif
|
2020-02-14 16:24:44 -05:00
|
|
|
>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string(
|
|
|
|
InputIterator first,
|
2020-02-21 11:26:27 -05:00
|
|
|
InputIterator last)
|
|
|
|
{
|
2020-02-21 20:01:22 -05:00
|
|
|
// KRYSTIAN TODO: we can use a better algorithm if this is a forward iterator
|
2020-02-21 11:26:27 -05:00
|
|
|
assign(first, last);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Construct a `basic_static_string`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Copy constructor.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2020-02-21 11:26:27 -05:00
|
|
|
basic_static_string(const basic_static_string& other) noexcept
|
|
|
|
{
|
|
|
|
assign(other);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Construct a `basic_static_string`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Copy constructor.
|
|
|
|
*/
|
|
|
|
template<std::size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string(
|
2020-02-21 11:26:27 -05:00
|
|
|
const basic_static_string<M, CharT, Traits>& other)
|
|
|
|
{
|
|
|
|
assign(other);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Construct a `basic_static_string`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Construct from an initializer list
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2020-02-21 11:26:27 -05:00
|
|
|
basic_static_string(std::initializer_list<value_type> init)
|
|
|
|
{
|
2020-02-21 20:01:22 -05:00
|
|
|
assign(init.begin(), init.size());
|
2020-02-21 11:26:27 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Construct a `basic_static_string`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-21 20:01:22 -05:00
|
|
|
Construct from a object convertible to `string_view_type`
|
2020-02-14 16:24:44 -05:00
|
|
|
*/
|
2020-02-21 20:01:22 -05:00
|
|
|
template<typename T
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
, typename = detail::enable_if_viewable_t<T, CharT, Traits>
|
|
|
|
#endif
|
|
|
|
>
|
2020-02-14 16:24:44 -05:00
|
|
|
explicit
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2020-02-21 20:01:22 -05:00
|
|
|
basic_static_string(const T& t)
|
2020-02-21 11:26:27 -05:00
|
|
|
{
|
2020-02-21 20:01:22 -05:00
|
|
|
assign(t);
|
2020-02-21 11:26:27 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Construct a `basic_static_string`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Construct from any object convertible to `string_view_type`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
The range (pos, n) is extracted from the value
|
|
|
|
obtained by converting `t` to `string_view_type`,
|
|
|
|
and used to construct the string.
|
|
|
|
*/
|
|
|
|
template<typename T
|
2019-12-16 12:23:46 -05:00
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
2020-02-21 19:00:54 -05:00
|
|
|
, typename = detail::enable_if_viewable_t<T, CharT, Traits>
|
2019-12-16 12:23:46 -05:00
|
|
|
#endif
|
2020-02-14 16:24:44 -05:00
|
|
|
>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string(
|
2020-02-14 17:21:54 -05:00
|
|
|
const T& t,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos,
|
2020-02-21 11:26:27 -05:00
|
|
|
size_type n)
|
|
|
|
{
|
|
|
|
assign(t, pos, n);
|
|
|
|
}
|
2020-02-14 16:24:44 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Assignment
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/** Assign to the string.
|
|
|
|
|
|
|
|
If `*this` and `s` are the same object,
|
|
|
|
this function has no effect.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
2020-02-14 17:21:54 -05:00
|
|
|
operator=(const basic_static_string& s) noexcept
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
|
|
|
return assign(s);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Assign to the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replace the contents with a copy of `s`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error if `s.size() > max_size()`
|
|
|
|
*/
|
|
|
|
template<std::size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
2020-02-14 17:21:54 -05:00
|
|
|
operator=(const basic_static_string<M, CharT, Traits>& s)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
|
|
|
return assign(s);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Assign to the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replace the contents with those of the null-terminated string `s`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 17:21:54 -05:00
|
|
|
@throw std::length_error if `traits_type::length(s) > max_size()`
|
2020-02-14 16:24:44 -05:00
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
2020-02-14 17:21:54 -05:00
|
|
|
operator=(const_pointer s)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
|
|
|
return assign(s);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Assign to the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Assign from single character.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
2020-02-14 17:21:54 -05:00
|
|
|
operator=(value_type ch)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
|
|
|
return assign_char(ch,
|
|
|
|
std::integral_constant<bool, (N > 0)>{});
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Assign to the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Assign from initializer list.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
2020-02-14 17:21:54 -05:00
|
|
|
operator=(std::initializer_list<value_type> ilist)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
|
|
|
return assign(ilist);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Assign to the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Assign from `string_view_type`.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
operator=(string_view_type sv)
|
|
|
|
{
|
|
|
|
return assign(sv);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace the contents.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replace the contents with `count` copies of character `ch`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error if `count > max_size()`
|
|
|
|
@return `*this`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
assign(
|
|
|
|
size_type count,
|
2020-02-14 17:21:54 -05:00
|
|
|
value_type ch);
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace the contents.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replace the contents with a copy of another `basic_static_string`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-21 19:21:48 -05:00
|
|
|
@throw std::length_error if `s.size() > max_size()`
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
|
|
|
*/
|
2020-02-21 19:21:48 -05:00
|
|
|
template<std::size_t M
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
, typename std::enable_if<(M < N)>::type* = nullptr
|
|
|
|
#endif
|
|
|
|
>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
assign(const basic_static_string<M, CharT, Traits>& s)
|
|
|
|
{
|
|
|
|
return assign_unchecked(s.data(), s.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
2020-02-21 15:37:22 -05:00
|
|
|
assign(const basic_static_string& s) noexcept
|
|
|
|
{
|
|
|
|
if (this == &s)
|
|
|
|
return *this;
|
2020-02-21 19:21:48 -05:00
|
|
|
return assign_unchecked(s.data(), s.size());
|
2020-02-21 15:37:22 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-21 19:21:48 -05:00
|
|
|
template<std::size_t M,
|
|
|
|
typename std::enable_if<(M > N)>::type* = nullptr>
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
2020-02-14 17:21:54 -05:00
|
|
|
assign(const basic_static_string<M, CharT, Traits>& s)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
|
|
|
return assign(s.data(), s.size());
|
|
|
|
}
|
2020-02-21 19:21:48 -05:00
|
|
|
#endif
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace the contents.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replace the contents with a copy of `count` characters starting at `npos` from `s`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error if `count > max_size()`
|
|
|
|
@return `*this`
|
|
|
|
*/
|
|
|
|
template<std::size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
assign(
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<M, CharT, Traits>& s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos,
|
2020-02-21 20:01:22 -05:00
|
|
|
size_type count = npos)
|
|
|
|
{
|
|
|
|
return assign(s.data() + pos, s.capped_length(pos, count));
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace the contents.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replace the contents with the first `count` characters of `s`, including nulls.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error if `count > max_size()`
|
|
|
|
@return `*this`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
assign(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type count);
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace the contents.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replace the contents with a copy of a null terminated string `s`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 17:21:54 -05:00
|
|
|
@throw std::length_error if `traits_type::length(s) > max_size()`
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
2020-02-14 17:21:54 -05:00
|
|
|
assign(const_pointer s)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
return assign(s, traits_type::length(s));
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace the contents.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replace the contents with a copy of characters from the range `(first, last)`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error if `std::distance(first, last) > max_size()`
|
|
|
|
@return `*this`
|
|
|
|
*/
|
|
|
|
template<typename InputIterator>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2019-12-16 12:23:46 -05:00
|
|
|
#ifdef GENERATING_DOCUMENTATION
|
2020-02-14 16:24:44 -05:00
|
|
|
basic_static_string&
|
2019-12-16 12:23:46 -05:00
|
|
|
#else
|
2020-02-14 16:24:44 -05:00
|
|
|
typename std::enable_if<
|
|
|
|
detail::is_input_iterator<InputIterator>::value,
|
|
|
|
basic_static_string&>::type
|
2019-12-16 12:23:46 -05:00
|
|
|
#endif
|
2020-02-14 16:24:44 -05:00
|
|
|
assign(
|
|
|
|
InputIterator first,
|
|
|
|
InputIterator last);
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace the contents.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replace the contents with the characters in an initializer list
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error if `ilist.size() > max_size()`
|
|
|
|
@return `*this`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
assign(
|
2020-02-14 17:21:54 -05:00
|
|
|
std::initializer_list<value_type> ilist)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
|
|
|
return assign(ilist.begin(), ilist.end());
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace the contents.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replace the contents with a copy of the characters from `string_view_type{t}`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error if `string_view_type{t}.size() > max_size()`
|
|
|
|
*/
|
2020-02-21 19:00:54 -05:00
|
|
|
template<typename T
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
, typename = detail::enable_if_viewable_t<T, CharT, Traits>
|
|
|
|
#endif
|
|
|
|
>
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
2020-02-14 17:21:54 -05:00
|
|
|
assign(const T& t)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
2020-02-21 19:30:34 -05:00
|
|
|
string_view_type sv = t;
|
|
|
|
return assign(sv.data(), sv.size());
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace the contents.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replace the contents with a copy of the characters from `string_view_type{t}.substr(pos, count)`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
The range `[pos, count)` is extracted from the value
|
|
|
|
obtained by converting `t` to `string_view_type`,
|
|
|
|
and used to assign the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::out_of_range if `pos > string_view_type{t}.size()`
|
|
|
|
@throw std::length_error if `string_view_type{t}.substr(pos, count).size() > max_size()`
|
|
|
|
*/
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-21 19:00:54 -05:00
|
|
|
template<typename T
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
, typename = detail::enable_if_viewable_t<T, CharT, Traits>
|
2019-12-16 12:23:46 -05:00
|
|
|
#endif
|
2020-02-21 19:00:54 -05:00
|
|
|
>
|
|
|
|
basic_static_string&
|
2020-02-14 16:24:44 -05:00
|
|
|
assign(
|
2020-02-14 17:21:54 -05:00
|
|
|
const T& t,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos,
|
|
|
|
size_type count = npos)
|
|
|
|
{
|
2020-02-21 19:00:54 -05:00
|
|
|
return assign(string_view_type(t).substr(pos, count));
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Element access
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Access specified character with bounds checking.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::out_of_range if `pos >= size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
reference
|
2020-02-21 11:26:27 -05:00
|
|
|
at(size_type pos)
|
|
|
|
{
|
|
|
|
BOOST_STATIC_STRING_THROW_IF(
|
|
|
|
pos >= size(), std::out_of_range{"pos >= size()"});
|
|
|
|
return data()[pos];
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Access specified character with bounds checking.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::out_of_range if `pos >= size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
const_reference
|
2020-02-21 11:26:27 -05:00
|
|
|
at(size_type pos) const
|
|
|
|
{
|
|
|
|
BOOST_STATIC_STRING_THROW_IF(
|
|
|
|
pos >= size(), std::out_of_range{"pos >= size()"});
|
|
|
|
return data()[pos];
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Access specified character
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Undefined behavior if `pos > size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
reference
|
|
|
|
operator[](size_type pos) noexcept
|
|
|
|
{
|
|
|
|
return data()[pos];
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Access specified character.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Undefined behavior if `pos > size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
const_reference
|
|
|
|
operator[](size_type pos) const noexcept
|
|
|
|
{
|
|
|
|
return data()[pos];
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Accesses the first character.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Undefined behavior if `empty() == true`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2020-02-14 17:21:54 -05:00
|
|
|
reference
|
2020-02-14 16:24:44 -05:00
|
|
|
front() noexcept
|
|
|
|
{
|
|
|
|
return data()[0];
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Accesses the first character.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Undefined behavior if `empty() == true`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2020-02-14 17:21:54 -05:00
|
|
|
const_reference
|
2020-02-14 16:24:44 -05:00
|
|
|
front() const noexcept
|
|
|
|
{
|
|
|
|
return data()[0];
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Accesses the last character.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Undefined behavior if `empty() == true`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2020-02-14 17:21:54 -05:00
|
|
|
reference
|
2020-02-14 16:24:44 -05:00
|
|
|
back() noexcept
|
|
|
|
{
|
|
|
|
return data()[size() - 1];
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Accesses the last character.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Undefined behavior if `empty() == true`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2020-02-14 17:21:54 -05:00
|
|
|
const_reference
|
2020-02-14 16:24:44 -05:00
|
|
|
back() const noexcept
|
|
|
|
{
|
|
|
|
return data()[size() - 1];
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns a pointer to the first character of the string.
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2020-02-14 17:21:54 -05:00
|
|
|
pointer
|
2020-02-14 16:24:44 -05:00
|
|
|
data() noexcept
|
|
|
|
{
|
|
|
|
return this->data_impl();
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns a pointer to the first character of a string.
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer
|
2020-02-14 16:24:44 -05:00
|
|
|
data() const noexcept
|
|
|
|
{
|
|
|
|
return this->data_impl();
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns a non-modifiable standard C character array version of the string.
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer
|
2020-02-14 16:24:44 -05:00
|
|
|
c_str() const noexcept
|
|
|
|
{
|
|
|
|
return data();
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Convert a static string to a `string_view_type`
|
|
|
|
BOOST_STATIC_STRING_CPP11_CONSTEXPR
|
|
|
|
operator string_view_type() const noexcept
|
|
|
|
{
|
2020-02-21 19:00:54 -05:00
|
|
|
return string_view_type(data(), size());
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Iterators
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns an iterator to the beginning.
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
iterator
|
|
|
|
begin() noexcept
|
|
|
|
{
|
|
|
|
return data();
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns an iterator to the beginning.
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
const_iterator
|
|
|
|
begin() const noexcept
|
|
|
|
{
|
|
|
|
return data();
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns an iterator to the beginning.
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
const_iterator
|
|
|
|
cbegin() const noexcept
|
|
|
|
{
|
|
|
|
return data();
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns an iterator to the end.
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
iterator
|
|
|
|
end() noexcept
|
|
|
|
{
|
2020-02-21 20:01:22 -05:00
|
|
|
return data() + size();
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns an iterator to the end.
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
const_iterator
|
|
|
|
end() const noexcept
|
|
|
|
{
|
2020-02-21 20:01:22 -05:00
|
|
|
return data() + size();
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns an iterator to the end.
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
const_iterator
|
|
|
|
cend() const noexcept
|
|
|
|
{
|
2020-02-21 20:01:22 -05:00
|
|
|
return data() + size();
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns a reverse iterator to the beginning.
|
|
|
|
BOOST_STATIC_STRING_CPP17_CONSTEXPR
|
|
|
|
reverse_iterator
|
|
|
|
rbegin() noexcept
|
|
|
|
{
|
|
|
|
return reverse_iterator{end()};
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns a reverse iterator to the beginning.
|
|
|
|
BOOST_STATIC_STRING_CPP17_CONSTEXPR
|
|
|
|
const_reverse_iterator
|
|
|
|
rbegin() const noexcept
|
|
|
|
{
|
|
|
|
return const_reverse_iterator{cend()};
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns a reverse iterator to the beginning.
|
|
|
|
BOOST_STATIC_STRING_CPP17_CONSTEXPR
|
|
|
|
const_reverse_iterator
|
|
|
|
crbegin() const noexcept
|
|
|
|
{
|
|
|
|
return const_reverse_iterator{cend()};
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns a reverse iterator to the end.
|
|
|
|
BOOST_STATIC_STRING_CPP17_CONSTEXPR
|
|
|
|
reverse_iterator
|
|
|
|
rend() noexcept
|
|
|
|
{
|
|
|
|
return reverse_iterator{begin()};
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns a reverse iterator to the end.
|
|
|
|
BOOST_STATIC_STRING_CPP17_CONSTEXPR
|
|
|
|
const_reverse_iterator
|
|
|
|
rend() const noexcept
|
|
|
|
{
|
|
|
|
return const_reverse_iterator{cbegin()};
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns a reverse iterator to the end.
|
|
|
|
BOOST_STATIC_STRING_CPP17_CONSTEXPR
|
|
|
|
const_reverse_iterator
|
|
|
|
crend() const noexcept
|
|
|
|
{
|
|
|
|
return const_reverse_iterator{cbegin()};
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Capacity
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns `true` if the string is empty.
|
|
|
|
BOOST_STATIC_STRING_NODISCARD
|
|
|
|
BOOST_STATIC_STRING_CPP11_CONSTEXPR
|
|
|
|
bool
|
|
|
|
empty() const noexcept
|
|
|
|
{
|
|
|
|
return size() == 0;
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns the number of characters, excluding the null terminator.
|
|
|
|
BOOST_STATIC_STRING_CPP11_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
size() const noexcept
|
|
|
|
{
|
|
|
|
return this->size_impl();
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Returns the number of characters, excluding the null terminator
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Equivalent to calling `size()`.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP11_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
length() const noexcept
|
|
|
|
{
|
|
|
|
return size();
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns the maximum number of characters that can be stored, excluding the null terminator.
|
|
|
|
BOOST_STATIC_STRING_CPP11_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
max_size() const noexcept
|
|
|
|
{
|
|
|
|
return N;
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Reserve space for `n` characters, excluding the null terminator
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
This function has no effect when `n <= max_size()`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error if `n > max_size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
void
|
2020-02-21 11:26:27 -05:00
|
|
|
reserve(size_type n)
|
|
|
|
{
|
|
|
|
BOOST_STATIC_STRING_THROW_IF(
|
|
|
|
n > max_size(), std::length_error{"n > max_size()"});
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Returns the number of characters that can be held in currently allocated storage.
|
|
|
|
|
|
|
|
This function always returns `max_size()`.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP11_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
capacity() const noexcept
|
|
|
|
{
|
|
|
|
return max_size();
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Reduces memory usage by freeing unused memory.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
This function call has no effect.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
void
|
|
|
|
shrink_to_fit() noexcept { }
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Operations
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Clears the contents
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
void
|
2020-02-21 11:26:27 -05:00
|
|
|
clear() noexcept
|
|
|
|
{
|
|
|
|
this->set_size(0);
|
|
|
|
term();
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Insert a character.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Inserts `count` copies of `ch` at the position `index`.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param index The index to insert at.
|
|
|
|
@param count The number of characters to insert.
|
|
|
|
@param ch The character to insert.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + count > max_size()`
|
|
|
|
@throw std::out_of_range `index > size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
insert(
|
|
|
|
size_type index,
|
|
|
|
size_type count,
|
2020-02-14 17:21:54 -05:00
|
|
|
value_type ch)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
|
|
|
BOOST_STATIC_STRING_THROW_IF(
|
|
|
|
index > size(), std::out_of_range{"index > size()"});
|
|
|
|
insert(begin() + index, count, ch);
|
|
|
|
return *this;
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Insert a string.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Inserts the null-terminated character string pointed to by `s`
|
|
|
|
of length `count` at the position `index` where `count`
|
2020-02-14 17:21:54 -05:00
|
|
|
is `traits_type::length(s)`.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param index The index to insert at.
|
|
|
|
@param s The string to insert.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + count > max_size()`
|
|
|
|
@throw std::out_of_range `index > size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
insert(
|
|
|
|
size_type index,
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
return insert(index, s, traits_type::length(s));
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Insert a string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Inserts `count` characters of the string pointed to by `s`
|
|
|
|
at the position `index`.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param index The index to insert at.
|
|
|
|
@param s The string to insert.
|
|
|
|
@param count The length of the string to insert.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + count > max_size()`
|
|
|
|
@throw std::out_of_range `index > size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
insert(
|
|
|
|
size_type index,
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-15 17:00:57 -05:00
|
|
|
size_type count)
|
|
|
|
{
|
|
|
|
BOOST_STATIC_STRING_THROW_IF(
|
|
|
|
index > size(), std::out_of_range{"index > size()"});
|
|
|
|
insert(data() + index, s, s + count);
|
|
|
|
return *this;
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Insert a string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Inserts the string `str`
|
|
|
|
at the position `index`.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note The insertion is done unchecked when
|
|
|
|
the capacity of `str` differs from that of the
|
|
|
|
string the function is called on.
|
2020-02-01 14:40:30 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@tparam M The size of the input string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param index The index to insert at.
|
|
|
|
@param str The string to insert.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + str.size() > max_size()`
|
|
|
|
@throw std::out_of_range `index > size()`
|
|
|
|
*/
|
|
|
|
template<std::size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
insert(
|
|
|
|
size_type index,
|
|
|
|
const basic_static_string<M, CharT, Traits>& str)
|
|
|
|
{
|
|
|
|
return insert_unchecked(index, str.data(), str.size());
|
|
|
|
}
|
2020-02-01 14:40:30 -05:00
|
|
|
|
2020-02-01 15:22:50 -05:00
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
insert(
|
|
|
|
size_type index,
|
|
|
|
const basic_static_string& str)
|
|
|
|
{
|
|
|
|
return insert(index, str.data(), str.size());
|
|
|
|
}
|
2020-02-01 15:22:50 -05:00
|
|
|
#endif
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Insert a string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Inserts a string, obtained by `str.substr(index_str, count)`
|
|
|
|
at the position `index`.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note The insertion is done unchecked when
|
|
|
|
the capacity of `str` differs from that of the
|
|
|
|
string the function is called on.
|
2020-02-01 14:40:30 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@tparam M The size of the input string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param index The index to insert at.
|
|
|
|
@param str The string from which to insert.
|
|
|
|
@param index_str The index in `str` to start inserting from.
|
|
|
|
@param count The number of characters to insert.
|
|
|
|
The default argument for this parameter is @ref npos.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + str.substr(index_str, count).size() > max_size()`
|
|
|
|
@throw std::out_of_range `index > size()`
|
|
|
|
@throw std::out_of_range `index_str > str.size()`
|
|
|
|
*/
|
|
|
|
template<std::size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
insert(
|
|
|
|
size_type index,
|
|
|
|
const basic_static_string<M, CharT, Traits>& str,
|
|
|
|
size_type index_str,
|
|
|
|
size_type count = npos)
|
|
|
|
{
|
2020-02-21 19:00:54 -05:00
|
|
|
return insert_unchecked(index, str.data() + index_str, str.capped_length(index_str, count));
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2020-02-01 14:40:30 -05:00
|
|
|
|
2020-02-01 15:22:50 -05:00
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
insert(
|
|
|
|
size_type index,
|
|
|
|
const basic_static_string& str,
|
|
|
|
size_type index_str,
|
|
|
|
size_type count = npos)
|
|
|
|
{
|
2020-02-21 19:00:54 -05:00
|
|
|
return insert(index, str.data() + index_str, str.capped_length(index_str, count));
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2020-02-01 15:22:50 -05:00
|
|
|
#endif
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Insert a character.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Inserts the character `ch` before the character pointed by `pos`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Precondition
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
`pos` shall be vaild within `[data(), data() + size()]`
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return An iterator which refers to the first inserted character
|
|
|
|
or `pos` if no characters were inserted
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param pos The index to insert at.
|
|
|
|
@param ch The character to insert.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + 1 > max_size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
iterator
|
|
|
|
insert(
|
|
|
|
const_iterator pos,
|
2020-02-14 17:21:54 -05:00
|
|
|
value_type ch)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
|
|
|
return insert(pos, 1, ch);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Insert characters.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Inserts `count` copies of `ch` before the character pointed by `pos`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Precondition
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
`pos` shall be valid within `[data(), data() + size()]`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return An iterator which refers to the first inserted character
|
|
|
|
or `pos` if no characters were inserted
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param pos The position to insert at.
|
|
|
|
@param count The number of characters to insert.
|
|
|
|
@param ch The character to insert.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + count > max_size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
iterator
|
|
|
|
insert(
|
|
|
|
const_iterator pos,
|
|
|
|
size_type count,
|
2020-02-14 17:21:54 -05:00
|
|
|
value_type ch);
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Insert a range of characters.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Inserts characters from the range `[first, last)` before the
|
|
|
|
character pointed to by `pos`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Precondition
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
`pos` shall be valid within `[data(), data() + size()]`,
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
`[first, last)` shall be a valid range
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@tparam InputIterator The type of the iterators.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Constraints
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
`InputIterator` satisfies __InputIterator__ and does not
|
|
|
|
satisfy __ForwardIterator__.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return An iterator which refers to the first inserted character
|
|
|
|
or `pos` if no characters were inserted
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param pos The position to insert at.
|
|
|
|
@param first An iterator representing the first character to insert.
|
|
|
|
@param last An iterator representing one past the last character to insert.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + insert_count > max_size()`
|
|
|
|
*/
|
|
|
|
template<typename InputIterator>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2020-02-21 19:00:54 -05:00
|
|
|
#ifdef GENERATING_DOCUMENTATION
|
2020-02-14 16:24:44 -05:00
|
|
|
iterator
|
2019-12-16 12:23:46 -05:00
|
|
|
#else
|
2020-02-14 16:24:44 -05:00
|
|
|
typename std::enable_if<
|
|
|
|
detail::is_input_iterator<
|
|
|
|
InputIterator>::value &&
|
|
|
|
!detail::is_forward_iterator<
|
|
|
|
InputIterator>::value, iterator>::type
|
2019-12-16 12:23:46 -05:00
|
|
|
#endif
|
2020-02-14 16:24:44 -05:00
|
|
|
insert(
|
|
|
|
const_iterator pos,
|
|
|
|
InputIterator first,
|
|
|
|
InputIterator last);
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 13:50:07 -05:00
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
2020-02-14 16:24:44 -05:00
|
|
|
template<typename ForwardIterator>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
typename std::enable_if<
|
|
|
|
detail::is_forward_iterator<
|
|
|
|
ForwardIterator>::value,
|
|
|
|
iterator>::type
|
|
|
|
insert(
|
|
|
|
const_iterator pos,
|
|
|
|
ForwardIterator first,
|
|
|
|
ForwardIterator last);
|
2020-02-14 13:50:07 -05:00
|
|
|
#endif
|
2019-12-30 21:12:20 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Insert characters from an initializer list.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Inserts characters from `ilist` before `pos`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Precondition
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
`pos` shall be valid within `[data(), data() + size()]`
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return An iterator which refers to the first inserted character
|
|
|
|
or `pos` if no characters were inserted
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param pos The position to insert at.
|
|
|
|
@param ilist The initializer list from which to insert.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + ilist.size() > max_size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
iterator
|
|
|
|
insert(
|
|
|
|
const_iterator pos,
|
2020-02-14 17:21:54 -05:00
|
|
|
std::initializer_list<value_type> ilist)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
2020-02-15 17:00:57 -05:00
|
|
|
return insert_unchecked(pos, ilist.begin(), ilist.size());
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Insert characters from an object convertible to `string_view_type`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Constructs a temporary `string_view_type` object `sv` from `t` and
|
|
|
|
inserts `[sv.begin(), sv.end())` at `index`.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Precondition
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
`index` shall be valid within `[data(), data() + size()]`
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@tparam T The type of the object to convert.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Constraints
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 17:21:54 -05:00
|
|
|
`std::is_convertible<const T&, string_view>::value &&
|
|
|
|
!std::is_convertible<const T&, const CharT*>::value`.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param index The index to insert at.
|
|
|
|
@param t The string to insert from.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + sv.size() > max_size()`
|
|
|
|
@throw std::out_of_range `index > size()`
|
|
|
|
*/
|
2020-02-21 19:00:54 -05:00
|
|
|
template<typename T
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
, typename = detail::enable_if_viewable_t<T, CharT, Traits>
|
|
|
|
#endif
|
|
|
|
>
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
insert(
|
|
|
|
size_type index,
|
2020-02-14 17:21:54 -05:00
|
|
|
const T& t)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
|
|
|
return insert(index, t, 0, npos);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Insert characters from an object convertible to `string_view_type`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Constructs a temporary `string_view_type` object `sv` from `t`
|
|
|
|
and inserts `sv.substr(index_str, count)` at `index`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@tparam T The type of the object to convert.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Constraints
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 17:21:54 -05:00
|
|
|
`std::is_convertible<const T&, string_view>::value &&
|
|
|
|
!std::is_convertible<const T&, const_pointer>::value`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param index The index to insert at.
|
|
|
|
@param t The string to insert from.
|
|
|
|
@param index_str The index in the temporary `string_view_type` object
|
|
|
|
to start the substring from.
|
|
|
|
@param count The number of characters to insert.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + sv.size() > max_size()`
|
|
|
|
@throw std::out_of_range `index > size()`
|
|
|
|
@throw std::out_of_range `index_str > sv.size()`
|
|
|
|
*/
|
2020-02-21 19:00:54 -05:00
|
|
|
template<typename T
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
, typename = detail::enable_if_viewable_t<T, CharT, Traits>
|
|
|
|
#endif
|
|
|
|
>
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
insert(
|
|
|
|
size_type index,
|
2020-02-14 17:21:54 -05:00
|
|
|
const T& t,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type index_str,
|
|
|
|
size_type count = npos)
|
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
const auto s = string_view_type(t).substr(index_str, count);
|
2020-02-14 16:24:44 -05:00
|
|
|
return insert(index, s.data(), s.size());
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Removes `min(count, size() - index)` characters starting at `index`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::out_of_range if `index > size()`
|
|
|
|
@return `*this`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
erase(
|
|
|
|
size_type index = 0,
|
2020-02-21 19:00:54 -05:00
|
|
|
size_type count = npos)
|
|
|
|
{
|
|
|
|
erase(data() + index, data() + index + capped_length(index, count));
|
|
|
|
return *this;
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Removes the character at `pos`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return iterator pointing to the character immediately following the character erased, or `end()` if no such character exists
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
iterator
|
2020-02-15 17:44:52 -05:00
|
|
|
erase(const_iterator pos)
|
|
|
|
{
|
|
|
|
BOOST_STATIC_STRING_ASSERT(!empty());
|
|
|
|
return erase(pos, pos + 1);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Removes the characters in the range `(first, last)`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return iterator pointing to the character last pointed to before the erase, or `end()` if no such character exists
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
iterator
|
|
|
|
erase(
|
|
|
|
const_iterator first,
|
|
|
|
const_iterator last);
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Appends the given character `ch` to the end of the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error if `1 > max_size() - size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
void
|
2020-02-14 17:21:54 -05:00
|
|
|
push_back(value_type ch);
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Removes the last character from the string
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
The behavior is undefined if the string is empty.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
void
|
|
|
|
pop_back() noexcept
|
|
|
|
{
|
2020-02-15 17:44:52 -05:00
|
|
|
BOOST_STATIC_STRING_ASSERT(!empty());
|
2020-02-14 16:24:44 -05:00
|
|
|
this->set_size(size() - 1);
|
|
|
|
term();
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Appends `count` copies of character `ch`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
The appended characters may be null.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error if `count > max_size() - size()`
|
|
|
|
@return `*this`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
append(
|
|
|
|
size_type count,
|
2020-02-21 19:00:54 -05:00
|
|
|
value_type ch);
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Append to the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-21 19:00:54 -05:00
|
|
|
Appends the string `s`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
The appended string can contain null characters.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-21 19:00:54 -05:00
|
|
|
@throw std::length_error if `s.size() > max_size() - size()`
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
|
|
|
*/
|
2020-02-21 19:00:54 -05:00
|
|
|
template<std::size_t M>
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
append(
|
2020-02-21 19:00:54 -05:00
|
|
|
const basic_static_string<M, CharT, Traits>& s)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
2020-02-21 19:00:54 -05:00
|
|
|
return append(s.data(), s.size());
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Append to the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-21 19:00:54 -05:00
|
|
|
Appends the contents of `s.substr(pos, count)`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
The appended string can contain null characters.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-21 19:00:54 -05:00
|
|
|
@throw std::out_of_range if `pos > s.size()`
|
|
|
|
@throw std::length_error if `s.substr(pos, count).size() > max_size() - size()`
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
|
|
|
*/
|
2020-02-21 19:00:54 -05:00
|
|
|
template<std::size_t M>
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
append(
|
2020-02-21 19:00:54 -05:00
|
|
|
const basic_static_string<M, CharT, Traits>& s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos,
|
|
|
|
size_type count = npos)
|
|
|
|
{
|
2020-02-21 19:00:54 -05:00
|
|
|
return append(s.data() + pos, s.capped_length(pos, count));
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Append to the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Appends characters in the range `(s, s + count)`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
The appended string can contain null characters.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error if `count > max_size() - size()`
|
|
|
|
@return `*this`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
append(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type count);
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Append to the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Appends the null-terminated character string pointed to by `s`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
The length of the string is determined by the first
|
2020-02-14 17:21:54 -05:00
|
|
|
null character using `traits_type::length(s)`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 17:21:54 -05:00
|
|
|
@throw std::length_error if `traits_type::length(s) > max_size() - size()`
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
2020-02-21 19:00:54 -05:00
|
|
|
append(const_pointer s)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
return append(s, traits_type::length(s));
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Append to the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Appends characters from the range `(first, last)`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
The inserted string can contain null characters.
|
|
|
|
This function does not participate in overload resolution if
|
|
|
|
`InputIterator` does not satisfy <em>LegacyInputIterator</em>
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error if `std::distance(first, last) > max_size() - size()`
|
|
|
|
@return `*this`
|
|
|
|
*/
|
|
|
|
template<typename InputIterator>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2020-02-21 19:00:54 -05:00
|
|
|
#ifdef GENERATING_DOCUMENTATION
|
2020-02-14 16:24:44 -05:00
|
|
|
basic_static_string&
|
2019-12-16 12:23:46 -05:00
|
|
|
#else
|
2020-02-14 16:24:44 -05:00
|
|
|
typename std::enable_if<
|
|
|
|
detail::is_input_iterator<InputIterator>::value,
|
|
|
|
basic_static_string&>::type
|
2019-12-16 12:23:46 -05:00
|
|
|
#endif
|
2020-02-14 16:24:44 -05:00
|
|
|
append(
|
|
|
|
InputIterator first,
|
2020-02-21 20:21:43 -05:00
|
|
|
InputIterator last)
|
|
|
|
{
|
|
|
|
this->set_size(size() + read_back(true, first, last));
|
|
|
|
return term();
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Append to the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Appends characters from initializer list `ilist`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
The appended string can contain null characters.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error if `ilist.size() > max_size() - size()`
|
|
|
|
@return `*this`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
append(
|
2020-02-14 17:21:54 -05:00
|
|
|
std::initializer_list<value_type> ilist)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
2020-02-21 19:00:54 -05:00
|
|
|
return append(ilist.begin(), ilist.size());
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Append to the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Appends characters from `string_view_type{t}`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
The appended string can contain null characters.
|
|
|
|
This function participates in overload resolution if
|
|
|
|
`T` is convertible to `string_view_type` and `T` is not
|
2020-02-14 17:21:54 -05:00
|
|
|
convertible to `const_pointer`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error if `string_view_type{t}.size() > max_size() - size()`
|
|
|
|
@return `*this`
|
|
|
|
*/
|
2020-02-21 19:00:54 -05:00
|
|
|
template<typename T
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
, typename = detail::enable_if_viewable_t<T, CharT, Traits>
|
|
|
|
#endif
|
|
|
|
>
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
2020-02-21 19:00:54 -05:00
|
|
|
append(const T& t)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
2020-02-21 19:00:54 -05:00
|
|
|
const string_view_type sv = t;
|
|
|
|
return append(sv.data(), sv.size());
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Append to the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Appends characters from `string_view_type{t}.substr{pos, count}`
|
|
|
|
|
|
|
|
The appended string can contain null characters.
|
|
|
|
This function participates in overload resolution if
|
|
|
|
`T` is convertible to `string_view_type` and `T` is not
|
2020-02-14 17:21:54 -05:00
|
|
|
convertible to `const_pointer`.
|
2020-02-14 16:24:44 -05:00
|
|
|
|
|
|
|
@throw std::out_of_range if `pos > string_view_type{t}.size()`
|
|
|
|
@throw std::length_error if `string_view_type{t}.substr(pos, count).size() > max_size() - size()`
|
|
|
|
@return `*this`
|
|
|
|
*/
|
2020-02-21 19:00:54 -05:00
|
|
|
template<typename T
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
, typename = detail::enable_if_viewable_t<T, CharT, Traits>
|
|
|
|
#endif
|
|
|
|
>
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
append(
|
2020-02-14 17:21:54 -05:00
|
|
|
const T& t,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos,
|
|
|
|
size_type count = npos)
|
|
|
|
{
|
2020-02-21 19:00:54 -05:00
|
|
|
return append(string_view_type(t).substr(pos, count));
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Append to the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error if `s.size() > max_size() - size()`
|
|
|
|
*/
|
|
|
|
template<std::size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
operator+=(
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<M, CharT, Traits>& s)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
2020-02-21 19:00:54 -05:00
|
|
|
return append(s);
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Append to the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Appends the given character `ch` to the end of the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error if `1 > max_size() - size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
2020-02-21 19:00:54 -05:00
|
|
|
operator+=(value_type ch)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
|
|
|
push_back(ch);
|
|
|
|
return *this;
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Append to the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Appends the null-terminated character string pointed to by `s`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
The length of the string is determined by the first
|
2020-02-14 17:21:54 -05:00
|
|
|
null character using `traits_type::length(s)`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 17:21:54 -05:00
|
|
|
@throw std::length_error if `traits_type::length(s) > max_size() - size()`
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
2020-02-21 19:00:54 -05:00
|
|
|
operator+=(const_pointer s)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
|
|
|
return append(s);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Append to the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Appends characters from initializer list `ilist`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
The appended string can contain null characters.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error if `ilist.size() > max_size() - size()`
|
|
|
|
@return `*this`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
operator+=(
|
2020-02-14 17:21:54 -05:00
|
|
|
std::initializer_list<value_type> ilist)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
|
|
|
return append(ilist);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Append to the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Appends a copy of the characters from `string_view_type{t}`
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
The appended string can contain null characters.
|
|
|
|
This function participates in overload resolution if
|
|
|
|
`T` is convertible to `string_view_type` and `T` is not
|
2020-02-14 17:21:54 -05:00
|
|
|
convertible to `const_pointer`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error if `string_view_type{t}.size() > max_size()`
|
|
|
|
*/
|
2020-02-21 19:00:54 -05:00
|
|
|
template<typename T
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
, typename = detail::enable_if_viewable_t<T, CharT, Traits>
|
|
|
|
#endif
|
|
|
|
>
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
operator+=(
|
2020-02-14 17:21:54 -05:00
|
|
|
const T& t)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
|
|
|
return append(t);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Compare the string with another.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Compares this string to `s`.
|
|
|
|
*/
|
|
|
|
template<std::size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
int
|
|
|
|
compare(
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<M, CharT, Traits>& s) const noexcept
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
|
|
|
return detail::lexicographical_compare<CharT, Traits>(
|
|
|
|
data(), size(), s.data(), s.size());
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Compare the string with another.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Compares a `[pos1, pos1+count1)` substring of this string to `s`. If `count1 > size() - pos1` the substring is `[pos1, size())`.
|
|
|
|
*/
|
|
|
|
template<std::size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
int
|
|
|
|
compare(
|
|
|
|
size_type pos1,
|
|
|
|
size_type count1,
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<M, CharT, Traits>& s) const
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
|
|
|
return detail::lexicographical_compare<CharT, Traits>(
|
2020-02-21 20:01:22 -05:00
|
|
|
data() + pos1, capped_length(pos1, count1), s.data(), s.size());
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Compare the string with another.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Compares a `[pos1, pos1+count1)` substring of this string to a substring `[pos2, pos2+count2)` of `s`.
|
|
|
|
If `count1 > size() - pos1` the first substring is `[pos1, size())`. Likewise, if `count2 > s.size() - pos2` the
|
|
|
|
second substring is `[pos2, s.size())`.
|
|
|
|
*/
|
|
|
|
template<std::size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
int
|
|
|
|
compare(
|
|
|
|
size_type pos1,
|
|
|
|
size_type count1,
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<M, CharT, Traits>& s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos2,
|
|
|
|
size_type count2 = npos) const
|
|
|
|
{
|
2020-02-21 20:01:22 -05:00
|
|
|
return detail::lexicographical_compare<CharT, Traits>(
|
|
|
|
data() + pos1, capped_length(pos1, count1),
|
|
|
|
s.data() + pos2, s.capped_length(pos2, count2));
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Compare the string with another.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 17:21:54 -05:00
|
|
|
Compares this string to the null-terminated character sequence beginning at the character pointed to by `s` with length `traits_type::length(s)`.
|
2020-02-14 16:24:44 -05:00
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
int
|
|
|
|
compare(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s) const noexcept
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
|
|
|
return detail::lexicographical_compare<CharT, Traits>(
|
2020-02-14 17:21:54 -05:00
|
|
|
data(), size(), s, traits_type::length(s));
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Compare the string with another.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Compares a `[pos1, pos1+count1)` substring of this string to the null-terminated character sequence beginning at the character pointed to by `s` with
|
2020-02-14 17:21:54 -05:00
|
|
|
length `traits_type::length(s)`. If `count1 > size() - pos1` the substring is `[pos1, size())`.
|
2020-02-14 16:24:44 -05:00
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
int
|
|
|
|
compare(
|
|
|
|
size_type pos1,
|
|
|
|
size_type count1,
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s) const
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
|
|
|
return detail::lexicographical_compare<CharT, Traits>(
|
2020-02-21 20:01:22 -05:00
|
|
|
data() + pos1, capped_length(pos1, count1), s, traits_type::length(s));
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Compare the string with another.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Compares a `[pos1, pos1+count1)` substring of this string to the characters in the range `[s, s + count2)`. If `count1 > size() - pos1` the substring is `[pos1, size())`.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
int
|
|
|
|
compare(
|
|
|
|
size_type pos1,
|
|
|
|
size_type count1,
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type count2) const
|
|
|
|
{
|
|
|
|
return detail::lexicographical_compare<CharT, Traits>(
|
2020-02-21 20:01:22 -05:00
|
|
|
data() + pos1, capped_length(pos1, count1), s, count2);
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Compare the string with another.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-21 19:30:34 -05:00
|
|
|
Compares this string to `t` after converting `t` to `string_view_type`.
|
|
|
|
|
|
|
|
This function participates in overload resolution if
|
|
|
|
`T` is convertible to `string_view_type` and `T` is not
|
|
|
|
convertible to `const_pointer`.
|
2020-02-14 16:24:44 -05:00
|
|
|
*/
|
2020-02-21 19:30:34 -05:00
|
|
|
template<typename T
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
, typename = detail::enable_if_viewable_t<T, CharT, Traits>
|
|
|
|
#endif
|
|
|
|
>
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
int
|
|
|
|
compare(
|
2020-02-21 19:30:34 -05:00
|
|
|
const T& t) const noexcept
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
2020-02-21 19:30:34 -05:00
|
|
|
string_view_type sv = t;
|
2020-02-14 16:24:44 -05:00
|
|
|
return detail::lexicographical_compare<CharT, Traits>(
|
2020-02-21 19:30:34 -05:00
|
|
|
data(), size(), t.data(), t.size());
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Compare the string with another.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-21 19:30:34 -05:00
|
|
|
Compares a `[pos1, pos1+count1)` substring of this string to `t` after converting it to
|
|
|
|
`string_view_type`. If `count1 > size() - pos1`
|
|
|
|
the substring is `[pos1, size())`.
|
|
|
|
|
|
|
|
This function participates in overload resolution if
|
|
|
|
`T` is convertible to `string_view_type` and `T` is not
|
|
|
|
convertible to `const_pointer`.
|
2020-02-14 16:24:44 -05:00
|
|
|
*/
|
2020-02-21 19:30:34 -05:00
|
|
|
template<typename T
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
, typename = detail::enable_if_viewable_t<T, CharT, Traits>
|
|
|
|
#endif
|
|
|
|
>
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
int
|
|
|
|
compare(
|
|
|
|
size_type pos1,
|
|
|
|
size_type count1,
|
2020-02-21 19:30:34 -05:00
|
|
|
const T& t) const
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
2020-02-21 20:01:22 -05:00
|
|
|
string_view_type sv = t;
|
2020-02-14 16:24:44 -05:00
|
|
|
return detail::lexicographical_compare<CharT, Traits>(
|
2020-02-21 20:01:22 -05:00
|
|
|
data() + pos1, capped_length(pos1, count1), sv.data(), sv.size());
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Compare the string with another.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replaces the part of the string indicated by `[pos1, pos1 + count1)` with a substring `[pos2, pos2 + count2)` of `t` after converting to `string_view_type`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
This function participates in overload resolution if
|
|
|
|
`T` is convertible to `string_view_type` and `T` is not
|
2020-02-14 17:21:54 -05:00
|
|
|
convertible to `const_pointer`.
|
2020-02-14 16:24:44 -05:00
|
|
|
*/
|
2020-02-21 19:00:54 -05:00
|
|
|
template<typename T
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
, typename = detail::enable_if_viewable_t<T, CharT, Traits>
|
|
|
|
#endif
|
|
|
|
>
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
int
|
|
|
|
compare(
|
|
|
|
size_type pos1,
|
|
|
|
size_type count1,
|
2020-02-14 17:21:54 -05:00
|
|
|
const T& t,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos2,
|
|
|
|
size_type count2 = npos) const
|
|
|
|
{
|
|
|
|
return compare(pos1, count1,
|
|
|
|
string_view_type(t).substr(pos2, count2));
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Return a substring.
|
2020-01-31 15:30:17 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Returns a substring of the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-31 15:30:17 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-31 15:30:17 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return A string object containing the characters
|
|
|
|
`[data() + pos, std::min(count, size() - pos))`.
|
2020-01-31 15:30:17 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param pos The index to being the substring at. The
|
|
|
|
default arugment for this parameter is `0`.
|
|
|
|
@param count The length of the substring. The default arugment
|
|
|
|
for this parameter is @ref npos.
|
2020-01-31 15:30:17 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::out_of_range `pos > size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string
|
|
|
|
substr(
|
|
|
|
size_type pos = 0,
|
2020-02-21 11:26:27 -05:00
|
|
|
size_type count = npos) const
|
|
|
|
{
|
2020-02-21 20:01:22 -05:00
|
|
|
return basic_static_string(data() + pos, capped_length(pos, count));
|
2020-02-21 11:26:27 -05:00
|
|
|
}
|
2020-01-31 15:30:17 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Return a view of a substring.
|
2020-01-31 15:30:17 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Returns a view of a substring.
|
2020-01-31 15:30:17 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return A `string_view_type` object referring
|
|
|
|
to `[data() + pos, std::min(count, size() - pos))`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param pos The index to being the substring at. The
|
|
|
|
default arugment for this parameter is `0`.
|
|
|
|
@param count The length of the substring. The default arugment
|
|
|
|
for this parameter is @ref npos.
|
2020-01-31 15:30:17 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::out_of_range `pos > size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
string_view_type
|
|
|
|
subview(
|
|
|
|
size_type pos = 0,
|
2020-02-21 11:26:27 -05:00
|
|
|
size_type count = npos) const
|
|
|
|
{
|
2020-02-21 20:01:22 -05:00
|
|
|
return string_view_type(data() + pos, capped_length(pos, count));
|
2020-02-21 11:26:27 -05:00
|
|
|
}
|
2020-02-14 16:24:44 -05:00
|
|
|
|
|
|
|
/** Copy a substring to another string.
|
|
|
|
|
|
|
|
Copies `std::min(count, size() - pos)` characters starting at
|
|
|
|
index `pos` to the string pointed to by `dest`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note The resulting string is not null terminated.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The number of characters copied.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param count The number of characters to copy.
|
|
|
|
@param dest The string to copy to.
|
|
|
|
@param pos The index to begin copying from. The
|
|
|
|
default argument for this parameter is `0`.
|
|
|
|
|
|
|
|
@throw std::out_of_range `pos > max_size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
copy(
|
2020-02-21 13:21:59 -05:00
|
|
|
pointer dest,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type count,
|
2020-02-21 20:21:43 -05:00
|
|
|
size_type pos = 0) const
|
|
|
|
{
|
|
|
|
const auto num_copied = capped_length(pos, count);
|
|
|
|
traits_type::copy(dest, data() + pos, num_copied);
|
|
|
|
return num_copied;
|
|
|
|
}
|
2020-02-14 16:24:44 -05:00
|
|
|
|
|
|
|
/** Change the size of the string.
|
|
|
|
|
|
|
|
Resizes the string to contain `n` characters. If
|
|
|
|
`n > size()`, characters with the value `CharT()` are
|
|
|
|
appended. Otherwise, `size()` is reduced to `n`.
|
|
|
|
|
|
|
|
@param n The size to resize the string to.
|
|
|
|
|
|
|
|
@throw std::out_of_range `n > max_size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
void
|
2020-02-21 20:01:22 -05:00
|
|
|
resize(size_type n)
|
|
|
|
{
|
|
|
|
resize(n, value_type());
|
|
|
|
}
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Change the size of the string.
|
|
|
|
|
|
|
|
Resizes the string to contain `n` characters. If
|
|
|
|
`n > size()`, copies of `c` are
|
|
|
|
appended. Otherwise, `size()` is reduced to `n`.
|
|
|
|
|
|
|
|
@param n The size to resize the string to.
|
|
|
|
@param c The characters to append if the size
|
|
|
|
increases.
|
|
|
|
|
|
|
|
@throw std::out_of_range `n > max_size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
void
|
|
|
|
resize(
|
|
|
|
size_type n,
|
2020-02-14 17:21:54 -05:00
|
|
|
value_type c);
|
2020-02-14 16:24:44 -05:00
|
|
|
|
|
|
|
/// Exchange the contents of this string with another.
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
void
|
|
|
|
swap(basic_static_string& s) noexcept;
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Exchange the contents of this string with another.
|
|
|
|
template<std::size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
void
|
|
|
|
swap(basic_static_string<M, CharT, Traits>& s);
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace a substring with a string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replaces `rcount` characters starting at index `pos1` with those
|
|
|
|
of `str`, where `rcount` is `std::min(n1, size() - pos1)`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-30 19:25:56 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note The replacement is done unchecked when
|
|
|
|
the capacity of `str` differs from that of the
|
|
|
|
string the function is called on.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@tparam M The size of the input string.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param pos1 The index to replace at.
|
|
|
|
@param n1 The number of characters to replace.
|
|
|
|
@param str The string to replace with.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + (str.size() - rcount) > max_size()`
|
|
|
|
@throw std::out_of_range `pos1 > size()`
|
|
|
|
*/
|
|
|
|
template<size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
replace(
|
|
|
|
size_type pos1,
|
|
|
|
size_type n1,
|
|
|
|
const basic_static_string<M, CharT, Traits>& str)
|
|
|
|
{
|
|
|
|
return replace_unchecked(pos1, n1, str.data(), str.size());
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-01 15:22:50 -05:00
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
replace(
|
|
|
|
size_type pos1,
|
|
|
|
size_type n1,
|
|
|
|
const basic_static_string& str)
|
|
|
|
{
|
|
|
|
return replace(pos1, n1, str.data(), str.size());
|
|
|
|
}
|
2020-02-01 15:22:50 -05:00
|
|
|
#endif
|
2020-01-01 15:38:41 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace a substring with a substring.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replaces `rcount` characters starting at index `pos1` with those of
|
|
|
|
`str.subview(pos2, n2)`, where `rcount` is `std::min(n1, size() - pos1)`.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note The replacement is done unchecked when
|
|
|
|
the capacity of `str` differs from that of the
|
|
|
|
string the function is called on.
|
2020-02-01 15:22:50 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
|
|
|
|
|
|
|
@return `*this`
|
|
|
|
|
|
|
|
@param pos1 The index to replace at.
|
|
|
|
@param n1 The number of characters to replace.
|
|
|
|
@param str The string to replace with.
|
|
|
|
@param pos2 The index to begin the substring.
|
|
|
|
@param n2 The length of the substring.
|
|
|
|
The default argument for this parameter is @ref npos.
|
|
|
|
|
|
|
|
@throw std::length_error `size() + (std::min(str.size(), n2) - rcount) > max_size()`
|
|
|
|
@throw std::out_of_range `pos1 > size()`
|
|
|
|
@throw std::out_of_range `pos2 > str.size()`
|
|
|
|
*/
|
|
|
|
template<std::size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
replace(
|
|
|
|
size_type pos1,
|
|
|
|
size_type n1,
|
|
|
|
const basic_static_string<M, CharT, Traits>& str,
|
|
|
|
size_type pos2,
|
|
|
|
size_type n2 = npos)
|
|
|
|
{
|
2020-02-21 19:00:54 -05:00
|
|
|
return replace_unchecked(pos1, n1, str.data() + pos2, str.capped_length(pos2, n2));
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-01 15:22:50 -05:00
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
replace(
|
|
|
|
size_type pos1,
|
|
|
|
size_type n1,
|
|
|
|
const basic_static_string& str,
|
|
|
|
size_type pos2,
|
|
|
|
size_type n2 = npos)
|
|
|
|
{
|
2020-02-21 19:00:54 -05:00
|
|
|
return replace(pos1, n1, str.data() + pos2, str.capped_length(pos2, n2));
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2020-02-01 15:22:50 -05:00
|
|
|
#endif
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace a substring with an object convertible to `string_view_type`.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Constructs a temporary `string_view_type` object `sv` from `t`, and
|
|
|
|
replaces `rcount` characters starting at index `pos1` with those
|
|
|
|
of `sv`, where `rcount` is `std::min(n1, size() - pos1)`.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@tparam T The type of the object to convert.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Constraints
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 17:21:54 -05:00
|
|
|
`std::is_convertible<const T&, string_view>::value &&
|
|
|
|
!std::is_convertible<const T&, const CharT*>::value`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param pos1 The index to replace at.
|
|
|
|
@param n1 The number of characters to replace.
|
|
|
|
@param t The object to replace with.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + (sv.size() - rcount) > max_size()`
|
|
|
|
@throw std::out_of_range `pos1 > size()`
|
|
|
|
*/
|
2020-02-21 19:00:54 -05:00
|
|
|
template<typename T
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
, typename = detail::enable_if_viewable_t<T, CharT, Traits>
|
|
|
|
#endif
|
|
|
|
>
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
replace(
|
|
|
|
size_type pos1,
|
|
|
|
size_type n1,
|
|
|
|
const T& t)
|
|
|
|
{
|
|
|
|
string_view_type sv = t;
|
|
|
|
return replace(pos1, n1, sv.data(), sv.size());
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace a substring with a substring of an object convertible to `string_view_type`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Constructs a temporary `string_view_type` object `sv` from `t`, and
|
|
|
|
replaces `rcount` characters starting at index `pos1` with those
|
|
|
|
of `sv.substr(pos2, n2)`, where `rcount` is `std::min(n1, size() - pos)`.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@tparam T The type of the object to convert.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Constraints
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 17:21:54 -05:00
|
|
|
`std::is_convertible<const T&, string_view>::value &&
|
|
|
|
!std::is_convertible<const T&, const CharT*>::value`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param pos1 The index to replace at.
|
|
|
|
@param n1 The number of characters to replace.
|
|
|
|
@param t The object to replace with.
|
|
|
|
@param pos2 The index to begin the substring.
|
|
|
|
@param n2 The length of the substring.
|
|
|
|
The default argument for this parameter is @ref npos.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + (std::min(n2, sv.size()) - rcount) > max_size()`
|
|
|
|
@throw std::out_of_range `pos1 > size()`
|
|
|
|
@throw std::out_of_range `pos2 > sv.size()`
|
|
|
|
*/
|
2020-02-21 19:00:54 -05:00
|
|
|
template<typename T
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
, typename = detail::enable_if_viewable_t<T, CharT, Traits>
|
|
|
|
#endif
|
|
|
|
>
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
replace(
|
|
|
|
size_type pos1,
|
|
|
|
size_type n1,
|
|
|
|
const T& t,
|
|
|
|
size_type pos2,
|
|
|
|
size_type n2 = npos)
|
|
|
|
{
|
|
|
|
string_view_type sv = t;
|
|
|
|
return replace(pos1, n1, sv.substr(pos2, n2));
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace a substring with a string.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replaces `rcount` characters starting at index `pos` with those of
|
|
|
|
`[s, s + n2)`, where `rcount` is `std::min(n1, size() - pos)`.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param pos The index to replace at.
|
|
|
|
@param n1 The number of characters to replace.
|
|
|
|
@param s The string to replace with.
|
|
|
|
@param n2 The length of the string to replace with.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + (n2 - rcount) > max_size()`
|
|
|
|
@throw std::out_of_range `pos > size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
replace(
|
|
|
|
size_type pos,
|
|
|
|
size_type n1,
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-15 17:00:57 -05:00
|
|
|
size_type n2)
|
|
|
|
{
|
2020-02-21 19:00:54 -05:00
|
|
|
return replace(data() + pos, data() + pos + capped_length(pos, n1), s, n2);
|
2020-02-15 17:00:57 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace a substring with a string.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replaces `rcount` characters starting at index `pos` with those of
|
2020-02-14 17:21:54 -05:00
|
|
|
`[s, s + len)`, where the length of the string `len` is `traits_type::length(s)` and `rcount`
|
2020-02-14 16:24:44 -05:00
|
|
|
is `std::min(n1, size() - pos)`.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param pos The index to replace at.
|
|
|
|
@param n1 The number of characters to replace.
|
|
|
|
@param s The string to replace with.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + (len - rcount) > max_size()`
|
|
|
|
@throw std::out_of_range `pos > size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
replace(
|
|
|
|
size_type pos,
|
|
|
|
size_type n1,
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
return replace(pos, n1, s, traits_type::length(s));
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace a substring with copies of a character.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replaces `rcount` characters starting at index `pos` with `n2` copies
|
|
|
|
of `c`, where `rcount` is `std::min(n1, size() - pos)`.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param pos The index to replace at.
|
|
|
|
@param n1 The number of characters to replace.
|
|
|
|
@param n2 The number of characters to replace with.
|
|
|
|
@param c The character to replace with.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + (n2 - rcount) > max_size()`
|
|
|
|
@throw std::out_of_range `pos > size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
replace(
|
|
|
|
size_type pos,
|
|
|
|
size_type n1,
|
|
|
|
size_type n2,
|
2020-02-15 17:00:57 -05:00
|
|
|
value_type c)
|
|
|
|
{
|
2020-02-21 19:00:54 -05:00
|
|
|
return replace(data() + pos, data() + pos + capped_length(pos, n1), n2, c);
|
2020-02-15 17:00:57 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace a range with a string.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replaces the characters in the range `[i1, i2)`
|
|
|
|
with those of `str`.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Precondition
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
`[i1, i2)` is a valid range.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-15 17:00:57 -05:00
|
|
|
@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
|
2020-02-14 16:24:44 -05:00
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@tparam M The size of the input string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param i1 An iterator referring to the first character to replace.
|
|
|
|
@param i2 An iterator referring past the end of
|
|
|
|
the last character to replace.
|
|
|
|
@param str The string to replace with.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + (str.size() - std::distance(i1, i2)) > max_size()`
|
|
|
|
*/
|
|
|
|
template<std::size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
replace(
|
|
|
|
const_iterator i1,
|
|
|
|
const_iterator i2,
|
|
|
|
const basic_static_string<M, CharT, Traits>& str)
|
2020-02-15 17:00:57 -05:00
|
|
|
{
|
|
|
|
return replace_unchecked(i1, i2, str.data(), str.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
replace(
|
|
|
|
const_iterator i1,
|
|
|
|
const_iterator i2,
|
|
|
|
const basic_static_string& str)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
|
|
|
return replace(i1, i2, str.data(), str.size());
|
|
|
|
}
|
2020-02-15 17:00:57 -05:00
|
|
|
#endif
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace a range with an object convertible to `string_view_type`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Constructs a temporary `string_view_type` object `sv` from `t`, and
|
|
|
|
replaces the characters in the range `[i1, i2)` with those
|
|
|
|
of `sv`.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Precondition
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
`[i1, i2)` is a valid range.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@tparam T The type of the object to convert.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Constraints
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 17:21:54 -05:00
|
|
|
`std::is_convertible<const T&, string_view>::value &&
|
|
|
|
!std::is_convertible<const T&, const CharT*>::value`.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param i1 An iterator referring to the first character to replace.
|
|
|
|
@param i2 An iterator referring past the end of
|
|
|
|
the last character to replace.
|
|
|
|
@param t The object to replace with.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + (sv.size() - std::distance(i1, i2)) > max_size()`
|
|
|
|
*/
|
2020-02-21 19:00:54 -05:00
|
|
|
template<typename T
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
, typename = detail::enable_if_viewable_t<T, CharT, Traits>
|
|
|
|
#endif
|
|
|
|
>
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
replace(
|
|
|
|
const_iterator i1,
|
|
|
|
const_iterator i2,
|
|
|
|
const T& t)
|
|
|
|
{
|
|
|
|
string_view_type sv = t;
|
2020-02-15 17:00:57 -05:00
|
|
|
return replace(i1, i2, sv.begin(), sv.end());
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace a range with a string.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replaces the characters in the range `[i1, i2)` with those of
|
|
|
|
`[s, s + n)`.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Precondition
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
`[i1, i2)` is a valid range.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param i1 An iterator referring to the first character to replace.
|
|
|
|
@param i2 An iterator referring past the end of
|
|
|
|
the last character to replace.
|
|
|
|
@param s The string to replace with.
|
|
|
|
@param n The length of the string to replace with.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + (n - std::distance(i1, i2)) > max_size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
replace(
|
|
|
|
const_iterator i1,
|
|
|
|
const_iterator i2,
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type n)
|
|
|
|
{
|
2020-02-15 17:00:57 -05:00
|
|
|
return replace(i1, i2, s, s + n);
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace a range with a string.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replaces the characters in the range `[i1, i2)` with those of
|
2020-02-14 17:21:54 -05:00
|
|
|
`[s, s + len)`, where the length of the string `len` is `traits_type::length(s)`.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Precondition
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
`[i1, i2)` shall be a valid range.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param i1 An iterator referring to the first character to replace.
|
|
|
|
@param i2 An iterator referring past the end of
|
|
|
|
the last character to replace.
|
|
|
|
@param s The string to replace with.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + (len - std::distance(i1, i2)) > max_size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
replace(
|
|
|
|
const_iterator i1,
|
|
|
|
const_iterator i2,
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
return replace(i1, i2, s, traits_type::length(s));
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace a range with copies of a character.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replaces the characters in the range `[i1, i2)` with
|
|
|
|
`n` copies of `c`.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Precondition
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
`[i1, i2)` is a valid range.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param i1 An iterator referring to the first character to replace.
|
|
|
|
@param i2 An iterator past the end of
|
|
|
|
the last character to replace.
|
|
|
|
@param n The number of characters to replace with.
|
|
|
|
@param c The character to replace with.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + (n - std::distance(i1, i2)) > max_size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
replace(
|
|
|
|
const_iterator i1,
|
|
|
|
const_iterator i2,
|
|
|
|
size_type n,
|
2020-02-15 17:00:57 -05:00
|
|
|
value_type c);
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace a range with a range.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replaces the characters in the range `[i1, i2)`
|
|
|
|
with those of `[j1, j2)`.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Precondition
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
`[i1, i2)` is a valid range.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
`[j1, j2)` is a valid range.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@tparam InputIterator The type of the iterators.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Constraints
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
`InputIterator` satisfies __InputIterator__ and does not
|
|
|
|
satisfy __ForwardIterator__.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param i1 An iterator referring to the first character to replace.
|
|
|
|
@param i2 An iterator referring past the end of
|
|
|
|
the last character to replace.
|
|
|
|
@param j1 An iterator referring to the first character to replace with.
|
|
|
|
@param j2 An iterator referring past the end of
|
|
|
|
the last character to replace with.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + (inserted - std::distance(i1, i2)) > max_size()`
|
|
|
|
*/
|
|
|
|
template<typename InputIterator>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2020-02-21 19:00:54 -05:00
|
|
|
#ifdef GENERATING_DOCUMENTATION
|
2020-02-14 16:24:44 -05:00
|
|
|
basic_static_string&
|
2019-12-16 12:23:46 -05:00
|
|
|
#else
|
2020-02-14 16:24:44 -05:00
|
|
|
typename std::enable_if<
|
|
|
|
detail::is_input_iterator<
|
|
|
|
InputIterator>::value &&
|
|
|
|
!detail::is_forward_iterator<
|
|
|
|
InputIterator>::value,
|
|
|
|
basic_static_string<N, CharT, Traits>&>::type
|
2019-12-16 12:23:46 -05:00
|
|
|
#endif
|
2020-02-14 16:24:44 -05:00
|
|
|
replace(
|
|
|
|
const_iterator i1,
|
|
|
|
const_iterator i2,
|
|
|
|
InputIterator j1,
|
|
|
|
InputIterator j2);
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 13:50:07 -05:00
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
2020-02-14 16:24:44 -05:00
|
|
|
template<typename ForwardIterator>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
typename std::enable_if<
|
|
|
|
detail::is_forward_iterator<
|
|
|
|
ForwardIterator>::value,
|
|
|
|
basic_static_string<N, CharT, Traits>&>::type
|
|
|
|
replace(
|
|
|
|
const_iterator i1,
|
|
|
|
const_iterator i2,
|
|
|
|
ForwardIterator j1,
|
|
|
|
ForwardIterator j2);
|
2020-02-14 13:50:07 -05:00
|
|
|
#endif
|
2019-12-30 21:12:20 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Replace a range with an initializer list.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Replaces the characters in the range `[i1, i2)`
|
|
|
|
with those of contained in the initializer list `il`.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Precondition
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
`[i1, i2)` is a valid range.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Exception Safety
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Strong guarantee.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note All references, pointers, or iterators
|
|
|
|
referring to contained elements are invalidated. Any
|
|
|
|
past-the-end iterators are also invalidated.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return `*this`
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param i1 An iterator referring to the first character to replace.
|
|
|
|
@param i2 An iterator past the end of
|
|
|
|
the last character to replace.
|
|
|
|
@param il The initializer list to replace with.
|
2020-01-29 23:35:31 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@throw std::length_error `size() + (il.size() - std::distance(i1, i2)) > max_size()`
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
replace(
|
|
|
|
const_iterator i1,
|
|
|
|
const_iterator i2,
|
2020-02-14 17:21:54 -05:00
|
|
|
std::initializer_list<value_type> il)
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
2020-02-15 17:00:57 -05:00
|
|
|
return replace_unchecked(i1, i2, il.begin(), il.size());
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Search
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the first occurrence of a string within the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Constructs a temporary `string_view_type` object `sv` from `t`, and finds
|
|
|
|
the first occurrence of `sv` within the string starting at the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note An empty string is always found.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@tparam T The type of the object to convert.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Constraints
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 17:21:54 -05:00
|
|
|
`std::is_convertible<const T&, string_view>::value &&
|
|
|
|
!std::is_convertible<const T&, const CharT*>::value`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The lowest index `idx` greater than or equal to `pos`
|
|
|
|
where each element of `[sv.begin(), sv.end())` is equal to
|
|
|
|
that of `[begin() + idx, begin() + idx + count)` if one exists,
|
|
|
|
and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param t The string to search for.
|
|
|
|
@param pos The index to start searching at. The default argument
|
|
|
|
for this parameter is `0`.
|
|
|
|
*/
|
2020-02-21 19:00:54 -05:00
|
|
|
template<typename T
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
, typename = detail::enable_if_viewable_t<T, CharT, Traits>
|
|
|
|
#endif
|
|
|
|
>
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find(
|
|
|
|
const T& t,
|
|
|
|
size_type pos = 0) const
|
|
|
|
noexcept(detail::is_nothrow_convertible<const T&, string_view_type>::value)
|
|
|
|
{
|
|
|
|
string_view_type sv = t;
|
|
|
|
return find(sv.data(), pos, sv.size());
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the first occurrence of a string within the string.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the first occurrence of `str` within the
|
|
|
|
string starting at the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@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.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param str The string to search for.
|
|
|
|
@param pos The index to start searching at. The default argument for
|
|
|
|
this parameter is `0`.
|
|
|
|
*/
|
|
|
|
template<std::size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find(
|
|
|
|
const basic_static_string<M, CharT, Traits>& str,
|
|
|
|
size_type pos = 0) const noexcept
|
|
|
|
{
|
|
|
|
return find(str.data(), pos, str.size());
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the first occurrence of a string within the string.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the first occurrence of the string pointed to
|
|
|
|
by `s` within the string starting at the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note An empty string is always found.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The lowest index `idx` greater than or equal to `pos`
|
|
|
|
where each element of `[s, s + n)` is equal to that of
|
|
|
|
`[begin() + idx, begin() + idx + n)` if one exists,
|
|
|
|
and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param s The string to search for.
|
|
|
|
@param pos The index to start searching at.
|
|
|
|
@param n The length of the string to search for.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos,
|
|
|
|
size_type n) const noexcept;
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the first occurrence of a string within the string.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the first occurrence of the string pointed to by `s`
|
|
|
|
of length `count` within the string starting at the index `pos`,
|
2020-02-14 17:21:54 -05:00
|
|
|
where `count` is `traits_type::length(s)`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@note An empty string is always found.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The lowest index `idx` greater than or equal to `pos`
|
|
|
|
where each element of `[s, s + count)` is equal to that of
|
|
|
|
`[begin() + idx, begin() + idx + count)` if one exists,
|
|
|
|
and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param s The string to search for.
|
|
|
|
@param pos The index to start searching at. The default argument
|
|
|
|
for this parameter is `0`.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos = 0) const noexcept
|
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
return find(s, pos, traits_type::length(s));
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the first occurrence of a character within the string.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the first occurrence of `c` within the string
|
|
|
|
starting at the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The index corrosponding to the first occurrence of `c` within
|
|
|
|
`[begin() + pos, end())` if it exists, and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param c The character to search for.
|
|
|
|
@param pos The index to start searching at. The default argument
|
|
|
|
for this parameter is `0`.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find(
|
2020-02-14 17:21:54 -05:00
|
|
|
value_type c,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos = 0) const noexcept
|
|
|
|
{
|
|
|
|
return find(&c, pos, 1);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the last occurrence of a string within the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Constructs a temporary `string_view_type` object `sv` from `t`, and finds
|
|
|
|
the last occurrence of `sv` within the string starting before or at
|
|
|
|
the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@tparam T The type of the object to convert.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Constraints
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 17:21:54 -05:00
|
|
|
`std::is_convertible<const T&, string_view>::value &&
|
|
|
|
!std::is_convertible<const T&, const CharT*>::value`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The highest index `idx` less than or equal to `pos`
|
|
|
|
where each element of `[sv.begin(), sv.end())` is equal to
|
|
|
|
that of `[begin() + idx, begin() + idx + count)` if one exists,
|
|
|
|
and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param t The string to search for.
|
|
|
|
@param pos The index to start searching at. The default argument
|
|
|
|
for this parameter is @ref npos.
|
|
|
|
*/
|
2020-02-21 19:00:54 -05:00
|
|
|
template<typename T
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
, typename = detail::enable_if_viewable_t<T, CharT, Traits>
|
|
|
|
#endif
|
|
|
|
>
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
rfind(
|
|
|
|
const T& t,
|
|
|
|
size_type pos = npos) const
|
|
|
|
noexcept(detail::is_nothrow_convertible<const T&, string_view_type>::value)
|
|
|
|
{
|
|
|
|
string_view_type sv = t;
|
|
|
|
return rfind(sv.data(), pos, sv.size());
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the last occurrence of a string within the string.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the last occurrence of `str` within the string
|
|
|
|
starting before or at the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The highest index `idx` less 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.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param str The string to search for.
|
|
|
|
@param pos The index to start searching at. The default argument for
|
|
|
|
this parameter is @ref npos.
|
|
|
|
*/
|
|
|
|
template<std::size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
rfind(
|
|
|
|
const basic_static_string<M, CharT, Traits>& str,
|
|
|
|
size_type pos = npos) const noexcept
|
|
|
|
{
|
|
|
|
return rfind(str.data(), pos, str.size());
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the last occurrence of a string within the string.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the last occurrence of the string pointed to
|
|
|
|
by `s` within the string starting before or at
|
|
|
|
the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The highest index `idx` less than or equal to `pos`
|
|
|
|
where each element of `[s, s + n)` is equal to that of
|
|
|
|
`[begin() + idx, begin() + idx + n)` if one exists,
|
|
|
|
and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param s The string to search for.
|
|
|
|
@param pos The index to start searching at.
|
|
|
|
@param n The length of the string to search for.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
rfind(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos,
|
|
|
|
size_type n) const noexcept;
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the last occurrence of a string within the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the last occurrence of the string pointed to by `s`
|
|
|
|
of length `count` within the string starting before or at the
|
2020-02-14 17:21:54 -05:00
|
|
|
index `pos`, where `count` is `traits_type::length(s)`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The highest index `idx` less than or equal to `pos`
|
|
|
|
where each element of `[s, s + count)` is equal to that of
|
|
|
|
`[begin() + idx, begin() + idx + count)` if one exists,
|
|
|
|
and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param s The string to search for.
|
|
|
|
@param pos The index to stop searching at. The default argument
|
|
|
|
for this parameter is @ref npos.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
rfind(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos = npos) const noexcept
|
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
return rfind(s, pos, traits_type::length(s));
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the last occurrence of a character within the string.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the last occurrence of `c` within the string
|
|
|
|
starting before or at the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The index corrosponding to the last occurrence of `c` within
|
|
|
|
`[begin(), begin() + pos]` if it exists, and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param c The character to search for.
|
|
|
|
@param pos The index to stop searching at. The default argument
|
|
|
|
for this parameter is @ref npos.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
rfind(
|
2020-02-14 17:21:54 -05:00
|
|
|
value_type c,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos = npos) const noexcept
|
|
|
|
{
|
|
|
|
return rfind(&c, pos, 1);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the first occurrence of any of the characters within the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Constructs a temporary `string_view_type` object `sv` from `t`, and finds
|
|
|
|
the first occurrence of any of the characters in `sv`
|
|
|
|
within the string starting at the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@tparam T The type of the object to convert.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Constraints
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 17:21:54 -05:00
|
|
|
`std::is_convertible<const T&, string_view>::value &&
|
|
|
|
!std::is_convertible<const T&, const CharT*>::value`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The index corrosponding to the first occurrence of
|
|
|
|
any of the characters in `[sv.begin(), sv.end())` within
|
|
|
|
`[begin() + pos, end())` if it exists, and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param t The characters to search for.
|
|
|
|
@param pos The index to start searching at. The default argument
|
|
|
|
for this parameter is `0`.
|
|
|
|
*/
|
2020-02-21 19:00:54 -05:00
|
|
|
template<typename T
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
, typename = detail::enable_if_viewable_t<T, CharT, Traits>
|
|
|
|
#endif
|
|
|
|
>
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find_first_of(
|
|
|
|
const T& t,
|
|
|
|
size_type pos = 0) const
|
|
|
|
noexcept(detail::is_nothrow_convertible<const T&, string_view_type>::value)
|
|
|
|
{
|
|
|
|
string_view_type sv = t;
|
|
|
|
return find_first_of(sv.data(), pos, sv.size());
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the first occurrence of any of the characters within the string.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the first occurrence of any of the characters within `str` within the
|
|
|
|
string starting at the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The index corrosponding to the first occurrence of any of the characters
|
|
|
|
of `str` within `[begin() + pos, end())` if it exists, and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param str The characters to search for.
|
|
|
|
@param pos The index to start searching at. The default argument for
|
|
|
|
this parameter is `0`.
|
|
|
|
*/
|
|
|
|
template<std::size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find_first_of(
|
|
|
|
const basic_static_string<M, CharT, Traits>& str,
|
|
|
|
size_type pos = 0) const noexcept
|
|
|
|
{
|
|
|
|
return find_first_of(str.data(), pos, str.size());
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the first occurrence of any of the characters within the string.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the first occurrence of any of the characters within the string pointed to
|
|
|
|
by `s` within the string starting at the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The index corrosponding to the first occurrence
|
|
|
|
of any of the characters in `[s, s + n)` within `[begin() + pos, end())`
|
|
|
|
if it exists, and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param s The characters to search for.
|
|
|
|
@param pos The index to start searching at.
|
|
|
|
@param n The length of the string to search for.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find_first_of(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos,
|
|
|
|
size_type n) const noexcept;
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the first occurrence of any of the characters within the string.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the first occurrence of the any of the characters within string
|
|
|
|
pointed to by `s` of length `count` within the string starting at the
|
2020-02-14 17:21:54 -05:00
|
|
|
index `pos`, where `count` is `traits_type::length(s)`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The index corrosponding to the first occurrence of any of
|
|
|
|
the characters in `[s, s + count)` within
|
|
|
|
`[begin() + pos, end())` if it exists, and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param s The characters to search for.
|
|
|
|
@param pos The index to start searching at. The default argument
|
|
|
|
for this parameter is `0`.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find_first_of(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos = 0) const noexcept
|
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
return find_first_of(s, pos, traits_type::length(s));
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the first occurrence of a character within the string.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the first occurrence of `c` within the string
|
|
|
|
starting at the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The index corrosponding to the first occurrence of `c` within
|
|
|
|
`[begin() + pos, end())` if it exists, and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param c The character to search for.
|
|
|
|
@param pos The index to start searching at. The default argument
|
|
|
|
for this parameter is `0`.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find_first_of(
|
2020-02-14 17:21:54 -05:00
|
|
|
value_type c,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos = 0) const noexcept
|
|
|
|
{
|
|
|
|
return find_first_of(&c, pos, 1);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the last occurrence of any of the characters within the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Constructs a temporary `string_view_type` object `sv` from `t`, and finds
|
|
|
|
the last occurrence of any of the characters in `sv`
|
|
|
|
within the string before or at the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@tparam T The type of the object to convert.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Constraints
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 17:21:54 -05:00
|
|
|
`std::is_convertible<const T&, string_view>::value &&
|
|
|
|
!std::is_convertible<const T&, const CharT*>::value`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The index corrosponding to the last occurrence of
|
|
|
|
any of the characters in `[sv.begin(), sv.end())` within
|
|
|
|
`[begin(), begin() + pos]` if it exists, and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param t The characters to search for.
|
|
|
|
@param pos The index to stop searching at. The default argument
|
|
|
|
for this parameter is @ref npos.
|
|
|
|
*/
|
2020-02-21 19:00:54 -05:00
|
|
|
template<typename T
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
, typename = detail::enable_if_viewable_t<T, CharT, Traits>
|
|
|
|
#endif
|
|
|
|
>
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find_last_of(
|
|
|
|
const T& t,
|
|
|
|
size_type pos = npos) const
|
|
|
|
noexcept(detail::is_nothrow_convertible<const T&, string_view_type>::value)
|
|
|
|
{
|
|
|
|
string_view_type sv = t;
|
|
|
|
return find_last_of(sv.data(), pos, sv.size());
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the last occurrence of any of the characters within the string.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the last occurrence of any of the characters within `str` within the
|
|
|
|
string starting before or at the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The index corrosponding to the last occurrence of any of the characters
|
|
|
|
of `str` within `[begin(), begin() + pos]` if it exists, and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param str The characters to search for.
|
|
|
|
@param pos The index to stop searching at. The default argument for
|
|
|
|
this parameter is @ref npos.
|
|
|
|
*/
|
|
|
|
template<std::size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find_last_of(
|
|
|
|
const basic_static_string<M, CharT, Traits>& str,
|
|
|
|
size_type pos = npos) const noexcept
|
|
|
|
{
|
|
|
|
return find_last_of(str.data(), pos, str.size());
|
|
|
|
}
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the last occurrence of any of the characters within the string.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the last occurrence of any of the characters within the string pointed to
|
|
|
|
by `s` within the string before or at the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
|
|
|
|
|
|
|
Linear.
|
|
|
|
|
|
|
|
@return The index corrosponding to the last occurrence
|
|
|
|
of any of the characters in `[s, s + n)` within `[begin(), begin() + pos]`
|
|
|
|
if it exists, and @ref npos otherwise.
|
|
|
|
|
|
|
|
@param s The characters to search for.
|
|
|
|
@param pos The index to stop searching at.
|
|
|
|
@param n The length of the string to search for.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find_last_of(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos,
|
|
|
|
size_type n) const noexcept;
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the last occurrence of any of the characters within the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the last occurrence of any of the characters within the string pointed to
|
|
|
|
by `s` of length `count` within the string before or at the index `pos`,
|
2020-02-14 17:21:54 -05:00
|
|
|
where `count` is `traits_type::length(s)`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The index corrosponding to the last occurrence
|
|
|
|
of any of the characters in `[s, s + count)` within `[begin(), begin() + pos]`
|
|
|
|
if it exists, and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param s The characters to search for.
|
|
|
|
@param pos The index to stop searching at. The default argument for
|
|
|
|
this parameter is @ref npos.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find_last_of(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos = npos) const noexcept
|
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
return find_last_of(s, pos, traits_type::length(s));
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the last occurrence of a character within the string.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the last occurrence of `c` within the string
|
|
|
|
before or at the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The index corrosponding to the last occurrence of `c` within
|
|
|
|
`[begin(), begin() + pos]` if it exists, and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param c The character to search for.
|
|
|
|
@param pos The index to stop searching at. The default argument
|
|
|
|
for this parameter is @ref npos.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find_last_of(
|
2020-02-14 17:21:54 -05:00
|
|
|
value_type c,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos = npos) const noexcept
|
|
|
|
{
|
|
|
|
return find_last_of(&c, pos, 1);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the first occurrence of a character not within the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Constructs a temporary `string_view_type` object `sv` from `t`, and finds
|
|
|
|
the first character that is not within `sv`, starting at the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@tparam T The type of the object to convert.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Constraints
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 17:21:54 -05:00
|
|
|
`std::is_convertible<const T&, string_view>::value &&
|
|
|
|
!std::is_convertible<const T&, const CharT*>::value`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The index corrosponding to the first occurrence of
|
|
|
|
a character that is not in `[sv.begin(), sv.end())` within
|
|
|
|
`[begin() + pos, end())` if it exists, and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param t The characters to ignore.
|
|
|
|
@param pos The index to start searching at. The default argument
|
|
|
|
for this parameter is `0`.
|
|
|
|
*/
|
2020-02-21 19:00:54 -05:00
|
|
|
template<typename T
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
, typename = detail::enable_if_viewable_t<T, CharT, Traits>
|
|
|
|
#endif
|
|
|
|
>
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find_first_not_of(
|
|
|
|
const T& t,
|
|
|
|
size_type pos = 0) const
|
|
|
|
noexcept(detail::is_nothrow_convertible<const T&, string_view_type>::value)
|
|
|
|
{
|
|
|
|
string_view_type sv = t;
|
|
|
|
return find_first_not_of(sv.data(), pos, sv.size());
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the first occurrence of any of the characters not within the string.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the first occurrence of a character that is not within `str`
|
|
|
|
within the string starting at the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The index corrosponding to the first character of `[begin() + pos, end())`
|
|
|
|
that is not within `str` if it exists, and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param str The characters to ignore.
|
|
|
|
@param pos The index to start searching at. The default argument for
|
|
|
|
this parameter is `0`.
|
|
|
|
*/
|
|
|
|
template<std::size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find_first_not_of(
|
|
|
|
const basic_static_string<M, CharT, Traits>& str,
|
|
|
|
size_type pos = 0) const noexcept
|
|
|
|
{
|
|
|
|
return find_first_not_of(str.data(), pos, str.size());
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the first occurrence of any of the characters not within the string.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the first occurrence of a character that is not within the string
|
|
|
|
pointed to by `s` within the string starting at the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The index corrosponding to the first character of `[begin() + pos, end())`
|
|
|
|
that is not within `[s, s + n)` if it exists, and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param s The characters to ignore.
|
|
|
|
@param pos The index to start searching at. The default argument for
|
|
|
|
this parameter is `0`.
|
|
|
|
@param n The length of the characters to ignore.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find_first_not_of(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos,
|
|
|
|
size_type n) const noexcept;
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the first occurrence of any of the characters not within the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the first occurrence of a character that is not within the string
|
|
|
|
pointed to by `s` of length `count` within the string starting
|
2020-02-14 17:21:54 -05:00
|
|
|
at the index `pos`, where `count` is `traits_type::length(s)`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The index corrosponding to the first character of `[begin() + pos, end())`
|
|
|
|
that is not within `[s, s + count)` if it exists, and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param s The characters to ignore.
|
|
|
|
@param pos The index to start searching at. The default argument for
|
|
|
|
this parameter is `0`.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find_first_not_of(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos = 0) const noexcept
|
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
return find_first_not_of(s, pos, traits_type::length(s));
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the first occurrence of a character not equal to `c`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the first occurrence of a character that is not equal
|
|
|
|
to `c`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The index corrosponding to the first character of `[begin() + pos, end())`
|
|
|
|
that is not equal to `c` if it exists, and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param c The character to ignore.
|
|
|
|
@param pos The index to start searching at. The default argument for
|
|
|
|
this parameter is `0`.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find_first_not_of(
|
2020-02-14 17:21:54 -05:00
|
|
|
value_type c,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos = 0) const noexcept
|
|
|
|
{
|
|
|
|
return find_first_not_of(&c, pos, 1);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the last occurrence of a character not within the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Constructs a temporary `string_view_type` object `sv` from `t`, and finds
|
|
|
|
the last character that is not within `sv`, starting at the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@tparam T The type of the object to convert.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Constraints
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 17:21:54 -05:00
|
|
|
`std::is_convertible<const T&, string_view>::value &&
|
|
|
|
!std::is_convertible<const T&, const CharT*>::value`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The index corrosponding to the last occurrence of
|
|
|
|
a character that is not in `[sv.begin(), sv.end())` within
|
|
|
|
`[begin(), begin() + pos]` if it exists, and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param t The characters to ignore.
|
|
|
|
@param pos The index to start searching at. The default argument
|
|
|
|
for this parameter is @ref npos.
|
|
|
|
*/
|
2020-02-21 19:00:54 -05:00
|
|
|
template<typename T
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
, typename = detail::enable_if_viewable_t<T, CharT, Traits>
|
|
|
|
#endif
|
|
|
|
>
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find_last_not_of(
|
|
|
|
const T& t,
|
|
|
|
size_type pos = npos) const
|
|
|
|
noexcept(detail::is_nothrow_convertible<const T&, string_view_type>::value)
|
|
|
|
{
|
|
|
|
string_view_type sv = t;
|
|
|
|
return find_last_not_of(sv.data(), pos, sv.size());
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the last occurrence of a character not within the string.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the last occurrence of a character that is not within `str`
|
|
|
|
within the string before or at the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The index corrosponding to the last character of `[begin(), begin() + pos]`
|
|
|
|
that is not within `str` if it exists, and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param str The characters to ignore.
|
|
|
|
@param pos The index to stop searching at. The default argument for
|
|
|
|
this parameter is @ref npos.
|
|
|
|
*/
|
|
|
|
template<size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find_last_not_of(
|
|
|
|
const basic_static_string<M, CharT, Traits>& str,
|
|
|
|
size_type pos = npos) const noexcept
|
|
|
|
{
|
|
|
|
return find_last_not_of(str.data(), pos, str.size());
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the last occurrence of a character not within the string.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the last occurrence of a character that is not within the
|
|
|
|
string pointed to by `s` within the string before or at the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The index corrosponding to the last character of `[begin(), begin() + pos]`
|
|
|
|
that is not within `[s, s + n)` if it exists, and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param s The characters to ignore.
|
|
|
|
@param pos The index to stop searching at. The default argument for
|
|
|
|
this parameter is @ref npos.
|
|
|
|
@param n The length of the characters to ignore.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find_last_not_of(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos,
|
|
|
|
size_type n) const noexcept;
|
2019-12-16 12:23:46 -05:00
|
|
|
|
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the last occurrence of a character not within the string.
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the last occurrence of a character that is not within the
|
|
|
|
string pointed to by `s` of length `count` within the string
|
2020-02-14 17:21:54 -05:00
|
|
|
before or at the index `pos`, where `count` is `traits_type::length(s)`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The index corrosponding to the last character of `[begin(), begin() + pos]`
|
|
|
|
that is not within `[s, s + count)` if it exists, and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param s The characters to ignore.
|
|
|
|
@param pos The index to stop searching at. The default argument for
|
|
|
|
this parameter is @ref npos.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find_last_not_of(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos = npos) const noexcept
|
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
return find_last_not_of(s, pos, traits_type::length(s));
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/** Find the last occurrence of a character not equal to `c`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Finds the last occurrence of a character that is not equal
|
|
|
|
to `c` before or at the index `pos`.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@par Complexity
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
Linear.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@return The index corrosponding to the last character of `[begin(), begin() + pos]`
|
|
|
|
that is not equal to `c` if it exists, and @ref npos otherwise.
|
2020-01-29 21:15:27 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
@param c The character to ignore.
|
|
|
|
@param pos The index to start searching at. The default argument for
|
|
|
|
this parameter is @ref npos.
|
|
|
|
*/
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
find_last_not_of(
|
2020-02-14 17:21:54 -05:00
|
|
|
value_type c,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos = npos) const noexcept
|
|
|
|
{
|
|
|
|
return find_last_not_of(&c, pos, 1);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns whether the string begins with `s`
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
bool
|
|
|
|
starts_with(
|
|
|
|
string_view_type s) const noexcept
|
|
|
|
{
|
|
|
|
const size_type len = s.size();
|
2020-02-14 17:21:54 -05:00
|
|
|
return size() >= len && !traits_type::compare(data(), s.data(), len);
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns whether the string begins with `c`
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
bool
|
|
|
|
starts_with(
|
2020-02-14 17:21:54 -05:00
|
|
|
value_type c) const noexcept
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
return !empty() && traits_type::eq(front(), c);
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns whether the string begins with `s`
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
bool
|
|
|
|
starts_with(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s) const noexcept
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
const size_type len = traits_type::length(s);
|
|
|
|
return size() >= len && !traits_type::compare(data(), s, len);
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns whether the string ends with `s`
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
bool
|
|
|
|
ends_with(
|
|
|
|
string_view_type s) const noexcept
|
|
|
|
{
|
|
|
|
const size_type len = s.size();
|
2020-02-14 17:21:54 -05:00
|
|
|
return size() >= len && !traits_type::compare(data() + (size() - len), s.data(), len);
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns whether the string ends with `c`
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
bool
|
|
|
|
ends_with(
|
2020-02-14 17:21:54 -05:00
|
|
|
value_type c) const noexcept
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
return !empty() && traits_type::eq(back(), c);
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
/// Returns whether the string begins with `s`
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
bool
|
|
|
|
ends_with(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s) const noexcept
|
2020-02-14 16:24:44 -05:00
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
const size_type len = traits_type::length(s);
|
|
|
|
return size() >= len && !traits_type::compare(data() + (size() - len), s, len);
|
2020-02-14 16:24:44 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
|
|
|
private:
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
2020-02-21 11:26:27 -05:00
|
|
|
term() noexcept
|
|
|
|
{
|
|
|
|
this->term_impl();
|
|
|
|
return *this;
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-02-21 11:26:27 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2020-02-14 16:24:44 -05:00
|
|
|
basic_static_string&
|
2020-02-21 11:26:27 -05:00
|
|
|
assign_char(value_type ch, std::true_type) noexcept
|
|
|
|
{
|
|
|
|
this->set_size(1);
|
|
|
|
traits_type::assign(data()[0], ch);
|
|
|
|
return term();
|
|
|
|
}
|
|
|
|
|
|
|
|
basic_static_string&
|
2020-02-21 13:21:59 -05:00
|
|
|
assign_char(value_type, std::false_type)
|
2020-02-21 11:26:27 -05:00
|
|
|
{
|
|
|
|
BOOST_STATIC_STRING_THROW(
|
|
|
|
std::length_error{"max_size() == 0"});
|
|
|
|
return *this;
|
|
|
|
}
|
2019-12-30 21:12:20 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
// Returns the size of data read from input iterator. Read data begins at data() + size() + 1.
|
|
|
|
template<typename InputIterator>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
read_back(
|
2020-02-21 19:00:54 -05:00
|
|
|
bool overwrite_null,
|
2020-02-14 16:24:44 -05:00
|
|
|
InputIterator first,
|
|
|
|
InputIterator last);
|
2020-01-01 15:01:39 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
replace_unchecked(
|
|
|
|
size_type pos,
|
|
|
|
size_type n1,
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-15 17:00:57 -05:00
|
|
|
size_type n2)
|
|
|
|
{
|
|
|
|
BOOST_STATIC_STRING_THROW_IF(
|
|
|
|
pos > size(), std::out_of_range{"pos > size()"});
|
2020-02-21 19:00:54 -05:00
|
|
|
return replace_unchecked(data() + pos, data() + pos + capped_length(pos, n1), s, n2);
|
2020-02-15 17:00:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
replace_unchecked(
|
|
|
|
const_iterator i1,
|
|
|
|
const_iterator i2,
|
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type n2);
|
2020-02-01 14:40:30 -05:00
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
insert_unchecked(
|
|
|
|
size_type index,
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-15 17:00:57 -05:00
|
|
|
size_type count)
|
|
|
|
{
|
|
|
|
BOOST_STATIC_STRING_THROW_IF(
|
|
|
|
index > size(), std::out_of_range{"index > size()"});
|
|
|
|
insert_unchecked(data() + index, s, count);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
iterator
|
|
|
|
insert_unchecked(
|
|
|
|
const_iterator pos,
|
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type count);
|
2020-02-21 19:00:54 -05:00
|
|
|
|
2020-02-21 19:21:48 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string&
|
|
|
|
assign_unchecked(
|
|
|
|
const_pointer s,
|
2020-02-21 20:21:43 -05:00
|
|
|
size_type count) noexcept
|
|
|
|
{
|
|
|
|
this->set_size(count);
|
|
|
|
traits_type::copy(data(), s, size() + 1);
|
|
|
|
return *this;
|
|
|
|
}
|
2020-02-21 19:21:48 -05:00
|
|
|
|
2020-02-21 19:00:54 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
size_type
|
|
|
|
capped_length(
|
|
|
|
size_type index,
|
|
|
|
size_type length) const
|
|
|
|
{
|
|
|
|
BOOST_STATIC_STRING_THROW_IF(
|
|
|
|
index > size(), std::out_of_range{"index > size()"});
|
|
|
|
return (std::min)(length, size() - index);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Non-member functions
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
template<
|
2020-02-14 16:24:44 -05:00
|
|
|
std::size_t N, std::size_t M,
|
|
|
|
typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2019-12-16 12:23:46 -05:00
|
|
|
inline
|
|
|
|
bool
|
|
|
|
operator==(
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<N, CharT, Traits>& lhs,
|
|
|
|
const basic_static_string<M, CharT, Traits>& rhs)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
return lhs.compare(rhs) == 0;
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<
|
2020-02-14 16:24:44 -05:00
|
|
|
std::size_t N, std::size_t M,
|
|
|
|
typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2019-12-16 12:23:46 -05:00
|
|
|
inline
|
|
|
|
bool
|
|
|
|
operator!=(
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<N, CharT, Traits>& lhs,
|
|
|
|
const basic_static_string<M, CharT, Traits>& rhs)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
return lhs.compare(rhs) != 0;
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<
|
2020-02-14 16:24:44 -05:00
|
|
|
std::size_t N, std::size_t M,
|
|
|
|
typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2019-12-16 12:23:46 -05:00
|
|
|
inline
|
|
|
|
bool
|
|
|
|
operator<(
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<N, CharT, Traits>& lhs,
|
|
|
|
const basic_static_string<M, CharT, Traits>& rhs)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
return lhs.compare(rhs) < 0;
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<
|
2020-02-14 16:24:44 -05:00
|
|
|
std::size_t N, std::size_t M,
|
|
|
|
typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2019-12-16 12:23:46 -05:00
|
|
|
inline
|
|
|
|
bool
|
|
|
|
operator<=(
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<N, CharT, Traits>& lhs,
|
|
|
|
const basic_static_string<M, CharT, Traits>& rhs)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
return lhs.compare(rhs) <= 0;
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<
|
2020-02-14 16:24:44 -05:00
|
|
|
std::size_t N, std::size_t M,
|
|
|
|
typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2019-12-16 12:23:46 -05:00
|
|
|
inline
|
|
|
|
bool
|
|
|
|
operator>(
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<N, CharT, Traits>& lhs,
|
|
|
|
const basic_static_string<M, CharT, Traits>& rhs)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
return lhs.compare(rhs) > 0;
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<
|
2020-02-14 16:24:44 -05:00
|
|
|
std::size_t N, std::size_t M,
|
|
|
|
typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2019-12-16 12:23:46 -05:00
|
|
|
inline
|
|
|
|
bool
|
|
|
|
operator>=(
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<N, CharT, Traits>& lhs,
|
|
|
|
const basic_static_string<M, CharT, Traits>& rhs)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
return lhs.compare(rhs) >= 0;
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2019-12-16 12:23:46 -05:00
|
|
|
inline
|
|
|
|
bool
|
|
|
|
operator==(
|
2020-02-14 17:21:54 -05:00
|
|
|
const CharT* lhs,
|
|
|
|
const basic_static_string<N, CharT, Traits>& rhs)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
return detail::lexicographical_compare<CharT, Traits>(
|
|
|
|
lhs, Traits::length(lhs),
|
|
|
|
rhs.data(), rhs.size()) == 0;
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2019-12-16 12:23:46 -05:00
|
|
|
inline
|
|
|
|
bool
|
|
|
|
operator==(
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<N, CharT, Traits>& lhs,
|
|
|
|
const CharT* rhs)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
return detail::lexicographical_compare<CharT, Traits>(
|
|
|
|
lhs.data(), lhs.size(),
|
|
|
|
rhs, Traits::length(rhs)) == 0;
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2019-12-16 12:23:46 -05:00
|
|
|
inline
|
|
|
|
bool
|
|
|
|
operator!=(
|
2020-02-14 17:21:54 -05:00
|
|
|
const CharT* lhs,
|
|
|
|
const basic_static_string<N, CharT, Traits>& rhs)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
return detail::lexicographical_compare<CharT, Traits>(
|
|
|
|
lhs, Traits::length(lhs),
|
|
|
|
rhs.data(), rhs.size()) != 0;
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2019-12-16 12:23:46 -05:00
|
|
|
inline
|
|
|
|
bool
|
|
|
|
operator!=(
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<N, CharT, Traits>& lhs,
|
|
|
|
const CharT* rhs)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
return detail::lexicographical_compare<CharT, Traits>(
|
|
|
|
lhs.data(), lhs.size(),
|
|
|
|
rhs, Traits::length(rhs)) != 0;
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2019-12-16 12:23:46 -05:00
|
|
|
inline
|
|
|
|
bool
|
|
|
|
operator<(
|
2020-02-14 17:21:54 -05:00
|
|
|
const CharT* lhs,
|
|
|
|
const basic_static_string<N, CharT, Traits>& rhs)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
return detail::lexicographical_compare<CharT, Traits>(
|
|
|
|
lhs, Traits::length(lhs),
|
|
|
|
rhs.data(), rhs.size()) < 0;
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2019-12-16 12:23:46 -05:00
|
|
|
inline
|
|
|
|
bool
|
|
|
|
operator<(
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<N, CharT, Traits>& lhs,
|
|
|
|
const CharT* rhs)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
return detail::lexicographical_compare<CharT, Traits>(
|
|
|
|
lhs.data(), lhs.size(),
|
|
|
|
rhs, Traits::length(rhs)) < 0;
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2019-12-16 12:23:46 -05:00
|
|
|
inline
|
|
|
|
bool
|
|
|
|
operator<=(
|
2020-02-14 17:21:54 -05:00
|
|
|
const CharT* lhs,
|
|
|
|
const basic_static_string<N, CharT, Traits>& rhs)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
return detail::lexicographical_compare<CharT, Traits>(
|
|
|
|
lhs, Traits::length(lhs),
|
|
|
|
rhs.data(), rhs.size()) <= 0;
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2019-12-16 12:23:46 -05:00
|
|
|
inline
|
|
|
|
bool
|
|
|
|
operator<=(
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<N, CharT, Traits>& lhs,
|
|
|
|
const CharT* rhs)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
return detail::lexicographical_compare<CharT, Traits>(
|
|
|
|
lhs.data(), lhs.size(),
|
|
|
|
rhs, Traits::length(rhs)) <= 0;
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2019-12-16 12:23:46 -05:00
|
|
|
inline
|
|
|
|
bool
|
|
|
|
operator>(
|
2020-02-14 17:21:54 -05:00
|
|
|
const CharT* lhs,
|
|
|
|
const basic_static_string<N, CharT, Traits>& rhs)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
return detail::lexicographical_compare<CharT, Traits>(
|
|
|
|
lhs, Traits::length(lhs),
|
|
|
|
rhs.data(), rhs.size()) > 0;
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2019-12-16 12:23:46 -05:00
|
|
|
inline
|
|
|
|
bool
|
|
|
|
operator>(
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<N, CharT, Traits>& lhs,
|
|
|
|
const CharT* rhs)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
return detail::lexicographical_compare<CharT, Traits>(
|
|
|
|
lhs.data(), lhs.size(),
|
|
|
|
rhs, Traits::length(rhs)) > 0;
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2019-12-16 12:23:46 -05:00
|
|
|
inline
|
|
|
|
bool
|
|
|
|
operator>=(
|
2020-02-14 17:21:54 -05:00
|
|
|
const CharT* lhs,
|
|
|
|
const basic_static_string<N, CharT, Traits>& rhs)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
return detail::lexicographical_compare<CharT, Traits>(
|
|
|
|
lhs, Traits::length(lhs),
|
|
|
|
rhs.data(), rhs.size()) >= 0;
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2019-12-16 12:23:46 -05:00
|
|
|
inline
|
|
|
|
bool
|
|
|
|
operator>=(
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<N, CharT, Traits>& lhs,
|
|
|
|
const CharT* rhs)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
return detail::lexicographical_compare<CharT, Traits>(
|
|
|
|
lhs.data(), lhs.size(),
|
|
|
|
rhs, Traits::length(rhs)) >= 0;
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
|
2019-12-16 16:42:53 -05:00
|
|
|
template<
|
2020-02-14 16:24:44 -05:00
|
|
|
std::size_t N, std::size_t M,
|
|
|
|
typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
inline
|
|
|
|
basic_static_string<N + M, CharT, Traits>
|
|
|
|
operator+(
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<N, CharT, Traits>& lhs,
|
|
|
|
const basic_static_string<M, CharT, Traits>& rhs)
|
2019-12-16 16:42:53 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
return basic_static_string<N + M, CharT, Traits>(lhs) += rhs;
|
2019-12-16 16:42:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
inline
|
|
|
|
basic_static_string<N + 1, CharT, Traits>
|
|
|
|
operator+(
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<N, CharT, Traits>& lhs,
|
2020-02-14 16:24:44 -05:00
|
|
|
CharT rhs)
|
2019-12-16 16:42:53 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
return basic_static_string<N + 1, CharT, Traits>(lhs) += rhs;
|
2019-12-16 16:42:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
inline
|
|
|
|
basic_static_string<N + 1, CharT, Traits>
|
|
|
|
operator+(
|
2020-02-14 16:24:44 -05:00
|
|
|
CharT lhs,
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<N, CharT, Traits>& rhs)
|
2019-12-16 16:42:53 -05:00
|
|
|
{
|
2020-02-21 12:44:25 -05:00
|
|
|
// The cast to std::size_t is needed here since 0 is a null pointer constant
|
|
|
|
return basic_static_string<N + 1, CharT, Traits>(rhs).insert(
|
|
|
|
std::size_t(0), 1, lhs);
|
2019-12-16 16:42:53 -05:00
|
|
|
}
|
|
|
|
|
2020-02-21 12:44:25 -05:00
|
|
|
// Add a null-terminated character array to a string.
|
2019-12-16 16:42:53 -05:00
|
|
|
template<
|
2020-02-14 16:24:44 -05:00
|
|
|
std::size_t N, std::size_t M,
|
|
|
|
typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
inline
|
2020-02-21 12:44:25 -05:00
|
|
|
basic_static_string<(N + M) - 1, CharT, Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
operator+(
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<N, CharT, Traits>& lhs,
|
2020-02-14 16:24:44 -05:00
|
|
|
const CharT(&rhs)[M])
|
2019-12-16 16:42:53 -05:00
|
|
|
{
|
2020-02-21 12:44:25 -05:00
|
|
|
// Subtract 1 to account for the null terminator, as "hello" is a char[6]
|
|
|
|
return basic_static_string<(N + M) - 1, CharT, Traits>(lhs).append(+rhs, M - 1);
|
2019-12-16 16:42:53 -05:00
|
|
|
}
|
|
|
|
|
2020-02-21 12:44:25 -05:00
|
|
|
// Add a string to a null-terminated character array.
|
2019-12-16 16:42:53 -05:00
|
|
|
template<
|
2020-02-14 16:24:44 -05:00
|
|
|
std::size_t N, std::size_t M,
|
|
|
|
typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
inline
|
2020-02-21 12:44:25 -05:00
|
|
|
basic_static_string<(N + M) - 1, CharT, Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
operator+(
|
2020-02-14 16:24:44 -05:00
|
|
|
const CharT(&lhs)[N],
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<M, CharT, Traits>& rhs)
|
2019-12-16 16:42:53 -05:00
|
|
|
{
|
2020-02-21 12:44:25 -05:00
|
|
|
// Subtract 1 to account for the null terminator, as "hello" is a char[6]
|
|
|
|
// The cast to std::size_t is needed here since 0 is a null pointer constant
|
|
|
|
return basic_static_string<(N + M) - 1, CharT, Traits>(rhs).insert(
|
|
|
|
std::size_t(0), +lhs, N - 1);
|
2019-12-16 16:42:53 -05:00
|
|
|
}
|
|
|
|
|
2019-12-16 12:23:46 -05:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// swap
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2020-02-14 16:24:44 -05:00
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2019-12-16 12:23:46 -05:00
|
|
|
inline
|
|
|
|
void
|
|
|
|
swap(
|
2020-02-14 16:24:44 -05:00
|
|
|
basic_static_string<N, CharT, Traits>& lhs,
|
|
|
|
basic_static_string<N, CharT, Traits>& rhs)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
lhs.swap(rhs);
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<
|
2020-02-14 16:24:44 -05:00
|
|
|
std::size_t N, std::size_t M,
|
|
|
|
typename CharT, typename Traits>
|
2019-12-16 16:42:53 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
2019-12-16 12:23:46 -05:00
|
|
|
inline
|
|
|
|
void
|
|
|
|
swap(
|
2020-02-14 16:24:44 -05:00
|
|
|
basic_static_string<N, CharT, Traits>& lhs,
|
|
|
|
basic_static_string<M, CharT, Traits>& rhs)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
lhs.swap(rhs);
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Input/Output
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
inline
|
|
|
|
std::basic_ostream<CharT, Traits>&
|
2020-02-14 16:24:44 -05:00
|
|
|
operator<<(
|
|
|
|
std::basic_ostream<CharT, Traits>& os,
|
2020-02-14 17:21:54 -05:00
|
|
|
const basic_static_string<N, CharT, Traits>& s)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-21 20:21:43 -05:00
|
|
|
return os << basic_string_view<CharT, Traits>(s.data(), s.size());
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Numeric conversions
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2020-01-15 16:41:51 -05:00
|
|
|
/// Converts `value` to a `static_string`
|
2020-02-22 15:43:52 -05:00
|
|
|
static_string<std::numeric_limits<int>::digits10 + 2>
|
2019-12-20 02:34:04 -05:00
|
|
|
inline
|
2020-02-01 16:30:23 -05:00
|
|
|
to_static_string(int value) noexcept
|
|
|
|
{
|
|
|
|
return detail::to_static_string_int_impl<
|
2020-02-22 15:43:52 -05:00
|
|
|
std::numeric_limits<int>::digits10 + 2>(value);
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
2020-01-15 16:41:51 -05:00
|
|
|
/// Converts `value` to a `static_string`
|
2020-02-22 15:43:52 -05:00
|
|
|
static_string<std::numeric_limits<long>::digits10 + 2>
|
2019-12-20 02:34:04 -05:00
|
|
|
inline
|
2020-02-01 16:30:23 -05:00
|
|
|
to_static_string(long value) noexcept
|
|
|
|
{
|
|
|
|
return detail::to_static_string_int_impl<
|
2020-02-22 15:43:52 -05:00
|
|
|
std::numeric_limits<long>::digits10 + 2>(value);
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
2019-12-20 02:34:04 -05:00
|
|
|
|
2020-01-15 16:41:51 -05:00
|
|
|
/// Converts `value` to a `static_string`
|
2020-02-22 15:43:52 -05:00
|
|
|
static_string<std::numeric_limits<long long>::digits10 + 2>
|
2019-12-20 02:34:04 -05:00
|
|
|
inline
|
2020-02-01 16:30:23 -05:00
|
|
|
to_static_string(long long value) noexcept
|
|
|
|
{
|
|
|
|
return detail::to_static_string_int_impl<
|
2020-02-22 15:43:52 -05:00
|
|
|
std::numeric_limits<long long>::digits10 + 2>(value);
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
2019-12-20 02:34:04 -05:00
|
|
|
|
2020-01-15 16:41:51 -05:00
|
|
|
/// Converts `value` to a `static_string`
|
2019-12-20 02:34:04 -05:00
|
|
|
static_string<std::numeric_limits<unsigned int>::digits10 + 1>
|
|
|
|
inline
|
2020-02-01 16:30:23 -05:00
|
|
|
to_static_string(unsigned int value) noexcept
|
|
|
|
{
|
|
|
|
return detail::to_static_string_int_impl<
|
|
|
|
std::numeric_limits<unsigned int>::digits10 + 1>(value);
|
|
|
|
}
|
2019-12-20 02:34:04 -05:00
|
|
|
|
2020-01-15 16:41:51 -05:00
|
|
|
/// Converts `value` to a `static_string`
|
2019-12-20 02:34:04 -05:00
|
|
|
static_string<std::numeric_limits<unsigned long>::digits10 + 1>
|
|
|
|
inline
|
2020-02-01 16:30:23 -05:00
|
|
|
to_static_string(unsigned long value) noexcept
|
|
|
|
{
|
|
|
|
return detail::to_static_string_int_impl<
|
|
|
|
std::numeric_limits<unsigned long>::digits10 + 1>(value);
|
|
|
|
}
|
2019-12-20 02:34:04 -05:00
|
|
|
|
2020-02-01 16:30:23 -05:00
|
|
|
/// Converts `value` to a `static_string`
|
2019-12-20 02:34:04 -05:00
|
|
|
static_string<std::numeric_limits<unsigned long long>::digits10 + 1>
|
|
|
|
inline
|
2020-02-01 16:30:23 -05:00
|
|
|
to_static_string(unsigned long long value) noexcept
|
|
|
|
{
|
|
|
|
return detail::to_static_string_int_impl<
|
|
|
|
std::numeric_limits<unsigned long long>::digits10 + 1>(value);
|
|
|
|
}
|
2019-12-20 02:34:04 -05:00
|
|
|
|
2020-02-01 16:30:23 -05:00
|
|
|
/// Converts `value` to a `static_string`
|
2019-12-20 02:34:04 -05:00
|
|
|
static_string<std::numeric_limits<float>::max_digits10 + 1>
|
|
|
|
inline
|
2020-02-01 16:30:23 -05:00
|
|
|
to_static_string(float value) noexcept
|
|
|
|
{
|
|
|
|
return detail::to_static_string_float_impl<
|
|
|
|
std::numeric_limits<float>::max_digits10 + 1>(value);
|
|
|
|
}
|
2019-12-20 02:34:04 -05:00
|
|
|
|
2020-02-01 16:30:23 -05:00
|
|
|
/// Converts `value` to a `static_string`
|
2019-12-20 02:34:04 -05:00
|
|
|
static_string<std::numeric_limits<double>::max_digits10 + 1>
|
|
|
|
inline
|
2020-02-01 16:30:23 -05:00
|
|
|
to_static_string(double value) noexcept
|
|
|
|
{
|
|
|
|
return detail::to_static_string_float_impl<
|
|
|
|
std::numeric_limits<double>::max_digits10 + 1>(value);
|
|
|
|
}
|
2019-12-20 02:34:04 -05:00
|
|
|
|
2020-01-15 16:41:51 -05:00
|
|
|
/// Converts `value` to a `static_string`
|
2019-12-20 02:34:04 -05:00
|
|
|
static_string<std::numeric_limits<long double>::max_digits10 + 1>
|
|
|
|
inline
|
2020-02-01 16:30:23 -05:00
|
|
|
to_static_string(long double value) noexcept
|
|
|
|
{
|
|
|
|
return detail::to_static_string_float_impl<
|
|
|
|
std::numeric_limits<long double>::max_digits10 + 1>(value);
|
|
|
|
}
|
2019-12-20 02:34:04 -05:00
|
|
|
|
2020-02-01 16:30:23 -05:00
|
|
|
/// Converts `value` to a `static_wstring`
|
2020-02-22 15:43:52 -05:00
|
|
|
static_wstring<std::numeric_limits<int>::digits10 + 2>
|
2019-12-20 02:34:04 -05:00
|
|
|
inline
|
2020-02-01 16:30:23 -05:00
|
|
|
to_static_wstring(int value) noexcept
|
|
|
|
{
|
|
|
|
return detail::to_static_wstring_int_impl<
|
2020-02-22 15:43:52 -05:00
|
|
|
std::numeric_limits<int>::digits10 + 2>(value);
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
2019-12-20 02:34:04 -05:00
|
|
|
|
2020-02-01 16:30:23 -05:00
|
|
|
/// Converts `value` to a `static_wstring`
|
2020-02-22 15:43:52 -05:00
|
|
|
static_wstring<std::numeric_limits<long>::digits10 + 2>
|
2019-12-20 02:34:04 -05:00
|
|
|
inline
|
2020-02-01 16:30:23 -05:00
|
|
|
to_static_wstring(long value) noexcept
|
|
|
|
{
|
|
|
|
return detail::to_static_wstring_int_impl<
|
2020-02-22 15:43:52 -05:00
|
|
|
std::numeric_limits<long>::digits10 + 2>(value);
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
2019-12-20 02:34:04 -05:00
|
|
|
|
2020-02-01 16:30:23 -05:00
|
|
|
/// Converts `value` to a `static_wstring`
|
2020-02-22 15:43:52 -05:00
|
|
|
static_wstring<std::numeric_limits<long long>::digits10 + 2>
|
2019-12-20 02:34:04 -05:00
|
|
|
inline
|
2020-02-01 16:30:23 -05:00
|
|
|
to_static_wstring(long long value) noexcept
|
|
|
|
{
|
|
|
|
return detail::to_static_wstring_int_impl<
|
2020-02-22 15:43:52 -05:00
|
|
|
std::numeric_limits<long long>::digits10 + 2>(value);
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
2019-12-20 02:34:04 -05:00
|
|
|
|
2020-02-01 16:30:23 -05:00
|
|
|
/// Converts `value` to a `static_wstring`
|
2019-12-20 02:34:04 -05:00
|
|
|
static_wstring<std::numeric_limits<unsigned int>::digits10 + 1>
|
|
|
|
inline
|
2020-02-01 16:30:23 -05:00
|
|
|
to_static_wstring(unsigned int value) noexcept
|
|
|
|
{
|
|
|
|
return detail::to_static_wstring_int_impl<
|
|
|
|
std::numeric_limits<unsigned int>::digits10 + 1>(value);
|
|
|
|
}
|
2019-12-20 02:34:04 -05:00
|
|
|
|
2020-02-01 16:30:23 -05:00
|
|
|
/// Converts `value` to a `static_wstring`
|
2019-12-20 02:34:04 -05:00
|
|
|
static_wstring<std::numeric_limits<unsigned long>::digits10 + 1>
|
2019-12-16 12:23:46 -05:00
|
|
|
inline
|
2020-02-01 16:30:23 -05:00
|
|
|
to_static_wstring(unsigned long value) noexcept
|
|
|
|
{
|
|
|
|
return detail::to_static_wstring_int_impl<
|
|
|
|
std::numeric_limits<unsigned long>::digits10 + 1>(value);
|
|
|
|
}
|
2019-12-20 02:34:04 -05:00
|
|
|
|
2020-02-01 16:30:23 -05:00
|
|
|
/// Converts `value` to a `static_wstring`
|
2019-12-20 02:34:04 -05:00
|
|
|
static_wstring<std::numeric_limits<unsigned long long>::digits10 + 1>
|
|
|
|
inline
|
2020-02-01 16:30:23 -05:00
|
|
|
to_static_wstring(unsigned long long value) noexcept
|
|
|
|
{
|
|
|
|
return detail::to_static_wstring_int_impl<
|
|
|
|
std::numeric_limits<unsigned long long>::digits10 + 1>(value);
|
|
|
|
}
|
2019-12-20 02:34:04 -05:00
|
|
|
|
2020-02-01 16:30:23 -05:00
|
|
|
/// Converts `value` to a `static_wstring`
|
2019-12-20 02:34:04 -05:00
|
|
|
static_wstring<std::numeric_limits<float>::max_digits10 + 1>
|
|
|
|
inline
|
2020-02-01 16:30:23 -05:00
|
|
|
to_static_wstring(float value) noexcept
|
|
|
|
{
|
|
|
|
return detail::to_static_wstring_float_impl<
|
|
|
|
std::numeric_limits<float>::max_digits10 + 1>(value);
|
|
|
|
}
|
2019-12-20 02:34:04 -05:00
|
|
|
|
2020-02-01 16:30:23 -05:00
|
|
|
/// Converts `value` to a `static_wstring`
|
2019-12-20 02:34:04 -05:00
|
|
|
static_wstring<std::numeric_limits<double>::max_digits10 + 1>
|
|
|
|
inline
|
2020-02-01 16:30:23 -05:00
|
|
|
to_static_wstring(double value) noexcept
|
|
|
|
{
|
|
|
|
return detail::to_static_wstring_float_impl<
|
|
|
|
std::numeric_limits<double>::max_digits10 + 1>(value);
|
|
|
|
}
|
2019-12-20 02:34:04 -05:00
|
|
|
|
2020-02-01 16:30:23 -05:00
|
|
|
/// Converts `value` to a `static_wstring`
|
2019-12-20 02:34:04 -05:00
|
|
|
static_wstring<std::numeric_limits<long double>::max_digits10 + 1>
|
|
|
|
inline
|
2020-02-01 16:30:23 -05:00
|
|
|
to_static_wstring(long double value) noexcept
|
|
|
|
{
|
|
|
|
return detail::to_static_wstring_float_impl<
|
|
|
|
std::numeric_limits<long double>::max_digits10 + 1>(value);
|
|
|
|
}
|
2019-12-16 12:23:46 -05:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Deduction Guides
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#ifdef BOOST_STATIC_STRING_USE_DEDUCT
|
|
|
|
template<std::size_t N, typename CharT>
|
|
|
|
basic_static_string(CharT(&)[N]) ->
|
2020-02-14 16:24:44 -05:00
|
|
|
basic_static_string<N, CharT, std::char_traits<CharT>>;
|
2019-12-16 12:23:46 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Hashing
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#ifndef BOOST_STATIC_STRING_STANDALONE
|
2020-01-15 13:23:44 -05:00
|
|
|
/// hash_value overload for Boost.Container_Hash
|
2019-12-16 12:23:46 -05:00
|
|
|
template <std::size_t N,
|
2020-02-14 16:24:44 -05:00
|
|
|
typename CharT,
|
|
|
|
typename Traits>
|
2019-12-16 12:23:46 -05:00
|
|
|
std::size_t
|
|
|
|
hash_value(
|
2020-02-14 16:24:44 -05:00
|
|
|
const basic_static_string<N, CharT, Traits>& str)
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
2020-02-14 16:24:44 -05:00
|
|
|
return boost::hash_range(str.begin(), str.end());
|
2019-12-16 12:23:46 -05:00
|
|
|
}
|
|
|
|
#endif
|
2019-12-26 17:22:57 -05:00
|
|
|
|
2019-12-16 12:23:46 -05:00
|
|
|
} // static_string
|
|
|
|
} // boost
|
|
|
|
|
2020-01-15 13:23:44 -05:00
|
|
|
/// std::hash partial specialization for basic_static_string
|
2020-02-14 17:21:54 -05:00
|
|
|
namespace std {
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
struct hash<
|
2020-02-21 19:00:54 -05:00
|
|
|
#ifdef GENERATING_DOCUMENTATION
|
2020-02-14 17:21:54 -05:00
|
|
|
basic_static_string
|
2020-01-15 13:23:44 -05:00
|
|
|
#else
|
2020-02-14 17:21:54 -05:00
|
|
|
boost::static_string::basic_static_string<N, CharT, Traits>
|
2020-01-15 13:23:44 -05:00
|
|
|
#endif
|
|
|
|
>
|
2020-02-14 17:21:54 -05:00
|
|
|
{
|
|
|
|
std::size_t
|
|
|
|
operator()(
|
|
|
|
const boost::static_string::basic_static_string<N, CharT, Traits>& str) const noexcept
|
2019-12-16 12:23:46 -05:00
|
|
|
{
|
|
|
|
#ifndef BOOST_STATIC_STRING_STANDALONE
|
2020-02-14 17:21:54 -05:00
|
|
|
return boost::hash_range(str.begin(), str.end());
|
2019-12-16 12:23:46 -05:00
|
|
|
#else
|
2020-02-21 20:01:22 -05:00
|
|
|
using view_type = typename
|
|
|
|
boost::static_string::basic_string_view<CharT, Traits>;
|
2020-02-14 18:18:51 -05:00
|
|
|
return std::hash<view_type>()(view_type(str.data(), str.size()));
|
2019-12-16 12:23:46 -05:00
|
|
|
#endif
|
2020-02-14 17:21:54 -05:00
|
|
|
}
|
|
|
|
};
|
2019-12-16 12:23:46 -05:00
|
|
|
} // std
|
|
|
|
|
2020-02-01 16:30:23 -05:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Implementation
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#ifndef GENERATING_DOCUMENTATION
|
|
|
|
namespace boost {
|
|
|
|
namespace static_string {
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
2020-02-14 17:21:54 -05:00
|
|
|
basic_static_string(const_pointer s)
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
const auto count = traits_type::length(s);
|
2020-02-01 16:30:23 -05:00
|
|
|
BOOST_STATIC_STRING_THROW_IF(count > max_size(),
|
2020-02-14 16:24:44 -05:00
|
|
|
std::length_error{"count > max_size()"});
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::copy(data(), s, count + 1);
|
2020-02-01 16:30:23 -05:00
|
|
|
this->set_size(count);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
auto
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
assign(
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type count,
|
2020-02-14 17:21:54 -05:00
|
|
|
value_type ch) ->
|
2020-02-14 16:24:44 -05:00
|
|
|
basic_static_string&
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
BOOST_STATIC_STRING_THROW_IF(count > max_size(),
|
2020-02-14 16:24:44 -05:00
|
|
|
std::length_error{"count > max_size()"});
|
2020-02-01 16:30:23 -05:00
|
|
|
this->set_size(count);
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::assign(data(), size(), ch);
|
2020-02-21 11:26:27 -05:00
|
|
|
return term();
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
auto
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
assign(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type count) ->
|
|
|
|
basic_static_string&
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
BOOST_STATIC_STRING_THROW_IF(count > max_size(),
|
2020-02-14 16:24:44 -05:00
|
|
|
std::length_error{"count > max_size()"});
|
2020-02-01 16:30:23 -05:00
|
|
|
this->set_size(count);
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::move(data(), s, size());
|
2020-02-21 11:26:27 -05:00
|
|
|
return term();
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
2020-02-21 19:30:34 -05:00
|
|
|
template<typename InputIterator>
|
2020-02-01 16:30:23 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
auto
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
assign(
|
2020-02-14 16:24:44 -05:00
|
|
|
InputIterator first,
|
|
|
|
InputIterator last) ->
|
|
|
|
typename std::enable_if<
|
|
|
|
detail::is_input_iterator<InputIterator>::value,
|
|
|
|
basic_static_string&>::type
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
auto ptr = data();
|
|
|
|
for (std::size_t i = 0; first != last; ++first, ++ptr, ++i)
|
|
|
|
{
|
2020-02-15 19:14:41 -05:00
|
|
|
if (i >= max_size())
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
this->set_size(i);
|
2020-02-15 19:14:41 -05:00
|
|
|
term();
|
2020-02-01 16:30:23 -05:00
|
|
|
BOOST_STATIC_STRING_THROW(std::length_error{"n > max_size()"});
|
|
|
|
}
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::assign(*ptr, *first);
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
|
|
|
this->set_size(ptr - data());
|
2020-02-21 11:26:27 -05:00
|
|
|
return term();
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
auto
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
insert(
|
2020-02-14 16:24:44 -05:00
|
|
|
const_iterator pos,
|
|
|
|
size_type count,
|
2020-02-14 17:21:54 -05:00
|
|
|
value_type ch) ->
|
2020-02-14 16:24:44 -05:00
|
|
|
iterator
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
const auto curr_size = size();
|
|
|
|
const auto curr_data = data();
|
|
|
|
BOOST_STATIC_STRING_THROW_IF(
|
2020-02-14 16:24:44 -05:00
|
|
|
count > max_size() - curr_size, std::length_error{"count() > max_size() - size()"});
|
2020-02-14 17:21:54 -05:00
|
|
|
const auto index = pos - curr_data;
|
2020-02-15 17:00:57 -05:00
|
|
|
traits_type::move(&curr_data[index + count], &curr_data[index], curr_size - index + 1);
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::assign(&curr_data[index], count, ch);
|
2020-02-01 16:30:23 -05:00
|
|
|
this->set_size(curr_size + count);
|
|
|
|
return &curr_data[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
2020-02-21 19:30:34 -05:00
|
|
|
template<typename ForwardIterator>
|
2020-02-01 16:30:23 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
auto
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
insert(
|
2020-02-14 16:24:44 -05:00
|
|
|
const_iterator pos,
|
|
|
|
ForwardIterator first,
|
|
|
|
ForwardIterator last) ->
|
|
|
|
typename std::enable_if<
|
|
|
|
detail::is_forward_iterator<
|
|
|
|
ForwardIterator>::value, iterator>::type
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
const auto curr_size = size();
|
|
|
|
const auto curr_data = data();
|
2020-02-14 13:50:07 -05:00
|
|
|
const std::size_t count = detail::distance(first, last);
|
|
|
|
const std::size_t index = pos - curr_data;
|
2020-02-01 16:30:23 -05:00
|
|
|
const auto s = &*first;
|
|
|
|
BOOST_STATIC_STRING_THROW_IF(
|
|
|
|
count > max_size() - curr_size, std::length_error{"count > max_size() - size()"});
|
2020-02-06 16:48:02 -05:00
|
|
|
const bool inside = detail::ptr_in_range(curr_data, curr_data + curr_size, s);
|
2020-02-01 16:30:23 -05:00
|
|
|
if (!inside || (inside && ((s - curr_data) + count <= index)))
|
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::move(&curr_data[index + count], &curr_data[index], curr_size - index + 1);
|
2020-02-01 16:30:23 -05:00
|
|
|
detail::copy_with_traits<Traits>(first, last, &curr_data[index]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const size_type offset = s - curr_data;
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::move(&curr_data[index + count], &curr_data[index], curr_size - index + 1);
|
2020-02-01 16:30:23 -05:00
|
|
|
if (offset < index)
|
|
|
|
{
|
|
|
|
const size_type diff = index - offset;
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::copy(&curr_data[index], &curr_data[offset], diff);
|
|
|
|
traits_type::copy(&curr_data[index + diff], &curr_data[index + count], count - diff);
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::copy(&curr_data[index], &curr_data[offset + count], count);
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
this->set_size(curr_size + count);
|
|
|
|
return curr_data + index;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
2020-02-21 19:30:34 -05:00
|
|
|
template<typename InputIterator>
|
2020-02-01 16:30:23 -05:00
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
auto
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
insert(
|
2020-02-14 16:24:44 -05:00
|
|
|
const_iterator pos,
|
|
|
|
InputIterator first,
|
|
|
|
InputIterator last) ->
|
|
|
|
typename std::enable_if<
|
|
|
|
detail::is_input_iterator<
|
|
|
|
InputIterator>::value &&
|
|
|
|
!detail::is_forward_iterator<
|
|
|
|
InputIterator>::value, iterator>::type
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
const auto curr_size = size();
|
|
|
|
const auto curr_data = data();
|
2020-02-21 19:00:54 -05:00
|
|
|
const auto count = read_back(false, first, last);
|
2020-02-15 17:00:57 -05:00
|
|
|
const std::size_t index = pos - curr_data;
|
2020-02-01 16:30:23 -05:00
|
|
|
std::rotate(&curr_data[index], &curr_data[curr_size + 1], &curr_data[curr_size + count + 1]);
|
|
|
|
this->set_size(curr_size + count);
|
|
|
|
return curr_data + index;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
auto
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
erase(
|
2020-02-14 16:24:44 -05:00
|
|
|
const_iterator first,
|
|
|
|
const_iterator last) ->
|
|
|
|
iterator
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
2020-02-15 17:44:52 -05:00
|
|
|
const auto curr_data = data();
|
|
|
|
const std::size_t index = first - curr_data;
|
|
|
|
traits_type::move(&curr_data[index], last, (end() - last) + 1);
|
|
|
|
this->set_size(size() - std::size_t(last - first));
|
|
|
|
return curr_data + index;
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
void
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
push_back(
|
2020-02-14 17:21:54 -05:00
|
|
|
value_type ch)
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
const auto curr_size = size();
|
|
|
|
BOOST_STATIC_STRING_THROW_IF(
|
2020-02-14 16:24:44 -05:00
|
|
|
curr_size >= max_size(), std::length_error{"size() >= max_size()"});
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::assign(data()[curr_size], ch);
|
2020-02-01 16:30:23 -05:00
|
|
|
this->set_size(curr_size + 1);
|
|
|
|
term();
|
|
|
|
}
|
|
|
|
|
2020-02-21 19:00:54 -05:00
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
auto
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
append(
|
|
|
|
size_type count,
|
|
|
|
value_type ch) ->
|
|
|
|
basic_static_string&
|
|
|
|
{
|
|
|
|
const auto curr_size = size();
|
|
|
|
BOOST_STATIC_STRING_THROW_IF(
|
|
|
|
count > max_size() - curr_size, std::length_error{"count > max_size() - size()"});
|
|
|
|
traits_type::assign(end(), count, ch);
|
|
|
|
this->set_size(curr_size + count);
|
|
|
|
return term();
|
|
|
|
}
|
|
|
|
|
2020-02-01 16:30:23 -05:00
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
auto
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
append(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type count) ->
|
|
|
|
basic_static_string&
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
const auto curr_size = size();
|
|
|
|
BOOST_STATIC_STRING_THROW_IF(
|
2020-02-14 16:24:44 -05:00
|
|
|
count > max_size() - curr_size, std::length_error{"count > max_size() - size()"});
|
2020-02-21 19:00:54 -05:00
|
|
|
traits_type::copy(end(), s, count);
|
2020-02-01 16:30:23 -05:00
|
|
|
this->set_size(curr_size + count);
|
2020-02-21 11:26:27 -05:00
|
|
|
return term();
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
void
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
2020-02-14 17:21:54 -05:00
|
|
|
resize(size_type n, value_type c)
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
BOOST_STATIC_STRING_THROW_IF(
|
2020-02-14 16:24:44 -05:00
|
|
|
n > max_size(), std::length_error{"n > max_size()"});
|
2020-02-14 23:19:57 -05:00
|
|
|
const auto curr_size = size();
|
2020-02-01 16:30:23 -05:00
|
|
|
if(n > curr_size)
|
2020-02-21 20:01:22 -05:00
|
|
|
traits_type::assign(data() + curr_size, n - curr_size, c);
|
2020-02-01 16:30:23 -05:00
|
|
|
this->set_size(n);
|
|
|
|
term();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
void
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
swap(basic_static_string& s) noexcept
|
|
|
|
{
|
|
|
|
const auto curr_size = size();
|
|
|
|
basic_static_string tmp(s);
|
|
|
|
s.set_size(curr_size);
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::copy(&s.data()[0], data(), curr_size + 1);
|
2020-02-01 16:30:23 -05:00
|
|
|
this->set_size(tmp.size());
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::copy(data(), tmp.data(), size() + 1);
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
template<std::size_t M>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
void
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
2020-02-07 13:50:14 -05:00
|
|
|
swap(basic_static_string<M, CharT, Traits>& s)
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
const auto curr_size = size();
|
|
|
|
BOOST_STATIC_STRING_THROW_IF(
|
2020-02-14 16:24:44 -05:00
|
|
|
curr_size > s.max_size(), std::length_error{"size() > s.max_size()"});
|
2020-02-01 16:30:23 -05:00
|
|
|
BOOST_STATIC_STRING_THROW_IF(
|
2020-02-14 16:24:44 -05:00
|
|
|
s.size() > max_size(), std::length_error{"s.size() > max_size()"});
|
2020-02-01 16:30:23 -05:00
|
|
|
basic_static_string tmp(s);
|
|
|
|
s.set_size(curr_size);
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::copy(&s.data()[0], data(), curr_size + 1);
|
2020-02-01 16:30:23 -05:00
|
|
|
this->set_size(tmp.size());
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::copy(data(), &tmp.data()[0], size() + 1);
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
auto
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
replace(
|
2020-02-15 17:00:57 -05:00
|
|
|
const_iterator i1,
|
|
|
|
const_iterator i2,
|
|
|
|
size_type n,
|
2020-02-14 17:21:54 -05:00
|
|
|
value_type c) ->
|
2020-02-14 16:24:44 -05:00
|
|
|
basic_static_string<N, CharT, Traits>&
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
const auto curr_size = size();
|
|
|
|
const auto curr_data = data();
|
2020-02-15 17:00:57 -05:00
|
|
|
const std::size_t n1 = i2 - i1;
|
2020-02-01 16:30:23 -05:00
|
|
|
BOOST_STATIC_STRING_THROW_IF(
|
2020-02-15 17:00:57 -05:00
|
|
|
n > max_size() ||
|
|
|
|
curr_size - n1 >= max_size() - n,
|
2020-02-14 16:24:44 -05:00
|
|
|
std::length_error{"replaced string exceeds max_size()"});
|
2020-02-15 17:00:57 -05:00
|
|
|
const auto pos = i1 - curr_data;
|
|
|
|
traits_type::move(&curr_data[pos + n], i2, (end() - i2) + 1);
|
|
|
|
traits_type::assign(&curr_data[pos], n, c);
|
|
|
|
this->set_size((curr_size - n1) + n);
|
2020-02-01 16:30:23 -05:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
template<typename ForwardIterator>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
auto
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
replace(
|
2020-02-14 16:24:44 -05:00
|
|
|
const_iterator i1,
|
|
|
|
const_iterator i2,
|
|
|
|
ForwardIterator j1,
|
|
|
|
ForwardIterator j2) ->
|
|
|
|
typename std::enable_if<
|
|
|
|
detail::is_forward_iterator<ForwardIterator>::value,
|
|
|
|
basic_static_string<N, CharT, Traits>&>::type
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
const auto curr_size = size();
|
|
|
|
const auto curr_data = data();
|
2020-02-15 17:00:57 -05:00
|
|
|
const auto first_addr = &*j1;
|
|
|
|
const std::size_t n1 = i2 - i1;
|
2020-02-01 16:30:23 -05:00
|
|
|
const std::size_t n2 = detail::distance(j1, j2);
|
|
|
|
const std::size_t pos = i1 - curr_data;
|
|
|
|
BOOST_STATIC_STRING_THROW_IF(
|
2020-02-15 17:00:57 -05:00
|
|
|
n2 > max_size() ||
|
2020-02-01 16:30:23 -05:00
|
|
|
curr_size - (std::min)(n1, curr_size - pos) >= max_size() - n2,
|
|
|
|
std::length_error{"replaced string exceeds max_size()"});
|
2020-02-14 13:50:07 -05:00
|
|
|
const bool inside = detail::ptr_in_range(curr_data, curr_data + curr_size, first_addr);
|
|
|
|
// due to short circuit evaluation, the second operand of the logical
|
|
|
|
// AND expression will only be evaluated if s is within the string,
|
|
|
|
// which means that operand of the cast will never be negative.
|
|
|
|
if (inside && std::size_t(first_addr - curr_data) == pos && n1 == n2)
|
2020-02-01 16:30:23 -05:00
|
|
|
return *this;
|
2020-02-14 13:50:07 -05:00
|
|
|
if (!inside || (inside && ((first_addr - curr_data) + n2 <= pos)))
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
// source outside
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::move(&curr_data[pos + n2], &curr_data[pos + n1], curr_size - pos - n1 + 1);
|
2020-02-01 16:30:23 -05:00
|
|
|
detail::copy_with_traits<Traits>(j1, j2, &curr_data[pos]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// source inside
|
2020-02-14 13:50:07 -05:00
|
|
|
const size_type offset = first_addr - curr_data;
|
2020-02-01 16:30:23 -05:00
|
|
|
if (n2 >= n1)
|
|
|
|
{
|
|
|
|
// grow/unchanged
|
2020-02-14 13:50:07 -05:00
|
|
|
const size_type diff = offset <= pos + n1 ? (std::min)((pos + n1) - offset, n2) : 0;
|
2020-02-01 16:30:23 -05:00
|
|
|
// shift all right of splice point by n2 - n1 to the right
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::move(&curr_data[pos + n2], &curr_data[pos + n1], curr_size - pos - n1 + 1);
|
2020-02-01 16:30:23 -05:00
|
|
|
// copy all before splice point
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::move(&curr_data[pos], &curr_data[offset], diff);
|
2020-02-01 16:30:23 -05:00
|
|
|
// copy all after splice point
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::move(&curr_data[pos + diff], &curr_data[(offset - n1) + n2 + diff], n2 - diff);
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// shrink
|
|
|
|
// copy all elements into place
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::move(&curr_data[pos], &curr_data[offset], n2);
|
2020-02-01 16:30:23 -05:00
|
|
|
// shift all elements after splice point left
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::move(&curr_data[pos + n2], &curr_data[pos + n1], curr_size - pos - n1 + 1);
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
|
|
|
}
|
2020-02-03 22:34:08 -05:00
|
|
|
this->set_size((curr_size - n1) + n2);
|
2020-02-01 16:30:23 -05:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
template<typename InputIterator>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
auto
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
replace(
|
2020-02-14 16:24:44 -05:00
|
|
|
const_iterator i1,
|
|
|
|
const_iterator i2,
|
|
|
|
InputIterator j1,
|
|
|
|
InputIterator j2) ->
|
|
|
|
typename std::enable_if<
|
|
|
|
detail::is_input_iterator<
|
|
|
|
InputIterator>::value &&
|
|
|
|
!detail::is_forward_iterator<
|
|
|
|
InputIterator>::value,
|
|
|
|
basic_static_string<N, CharT, Traits>&>::type
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
const auto curr_size = size();
|
|
|
|
const auto curr_data = data();
|
2020-02-15 17:00:57 -05:00
|
|
|
const std::size_t n1 = detail::distance(i1, i2);
|
2020-02-21 19:00:54 -05:00
|
|
|
const std::size_t n2 = read_back(false, j1, j2);
|
2020-02-01 16:30:23 -05:00
|
|
|
const std::size_t pos = i1 - curr_data;
|
|
|
|
BOOST_STATIC_STRING_THROW_IF(
|
2020-02-15 17:00:57 -05:00
|
|
|
n2 > max_size() ||
|
2020-02-01 16:30:23 -05:00
|
|
|
curr_size - (std::min)(n1, curr_size - pos) >= max_size() - n2,
|
|
|
|
std::length_error{"replaced string exceeds max_size()"});
|
2020-02-15 17:00:57 -05:00
|
|
|
// 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
|
2020-02-01 16:30:23 -05:00
|
|
|
std::rotate(&curr_data[pos], &curr_data[curr_size + 1], &curr_data[curr_size + n2 + 1]);
|
2020-02-15 17:00:57 -05:00
|
|
|
// Move everything from the end of the splice point to the end of the rotated string to
|
|
|
|
// the begining of the splice point
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::move(&curr_data[pos + n2], &curr_data[pos + n2 + n1], ((curr_size - n1) + n2) - pos);
|
2020-02-03 22:34:08 -05:00
|
|
|
this->set_size((curr_size - n1) + n2);
|
2020-02-01 16:30:23 -05:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
auto
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
find(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos,
|
|
|
|
size_type n) const noexcept ->
|
|
|
|
size_type
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
const auto curr_size = size();
|
|
|
|
if (pos > curr_size || n > curr_size - pos)
|
|
|
|
return npos;
|
|
|
|
if (!n)
|
|
|
|
return pos;
|
2020-02-21 20:01:22 -05:00
|
|
|
const auto res = detail::search(data() + pos, data() + curr_size, s, s + n, traits_type::eq);
|
2020-02-01 16:30:23 -05:00
|
|
|
return res == end() ? npos : detail::distance(data(), res);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
auto
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
rfind(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos,
|
|
|
|
size_type n) const noexcept ->
|
|
|
|
size_type
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
const auto curr_size = size();
|
|
|
|
const auto curr_data = data();
|
|
|
|
if (curr_size < n)
|
|
|
|
return npos;
|
|
|
|
if (pos > curr_size - n)
|
|
|
|
pos = curr_size - n;
|
|
|
|
if (!n)
|
|
|
|
return pos;
|
|
|
|
for (auto sub = &curr_data[pos]; sub >= curr_data; --sub)
|
2020-02-14 17:21:54 -05:00
|
|
|
if (!traits_type::compare(sub, s, n))
|
2020-02-01 16:30:23 -05:00
|
|
|
return detail::distance(curr_data, sub);
|
|
|
|
return npos;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
auto
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
find_first_of(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos,
|
|
|
|
size_type n) const noexcept ->
|
|
|
|
size_type
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
const auto curr_data = data();
|
|
|
|
if (pos >= size() || !n)
|
|
|
|
return npos;
|
2020-02-14 17:21:54 -05:00
|
|
|
const auto res = detail::find_first_of(&curr_data[pos], &curr_data[size()], s, &s[n], traits_type::eq);
|
2020-02-01 16:30:23 -05:00
|
|
|
return res == end() ? npos : detail::distance(curr_data, res);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
auto
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
find_last_of(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos,
|
|
|
|
size_type n) const noexcept ->
|
|
|
|
size_type
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
const auto curr_size = size();
|
|
|
|
if (!n)
|
|
|
|
return npos;
|
|
|
|
if (pos >= curr_size)
|
|
|
|
pos = 0;
|
|
|
|
else
|
|
|
|
pos = curr_size - (pos + 1);
|
2020-02-14 17:21:54 -05:00
|
|
|
const auto res = detail::find_first_of(rbegin() + pos, rend(), s, &s[n], traits_type::eq);
|
2020-02-01 16:30:23 -05:00
|
|
|
return res == rend() ? npos : curr_size - 1 - detail::distance(rbegin(), res);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
auto
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
find_first_not_of(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos,
|
|
|
|
size_type n) const noexcept ->
|
|
|
|
size_type
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
if (pos >= size())
|
|
|
|
return npos;
|
|
|
|
if (!n)
|
|
|
|
return pos;
|
2020-02-21 20:01:22 -05:00
|
|
|
const auto res = detail::find_not_of<Traits>(data() + pos, data() + size(), s, n);
|
2020-02-01 16:30:23 -05:00
|
|
|
return res == end() ? npos : detail::distance(data(), res);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
auto
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
find_last_not_of(
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type pos,
|
|
|
|
size_type n) const noexcept ->
|
|
|
|
size_type
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
const auto curr_size = size();
|
|
|
|
if (pos >= curr_size)
|
|
|
|
pos = curr_size - 1;
|
|
|
|
if (!n)
|
|
|
|
return pos;
|
|
|
|
pos = curr_size - (pos + 1);
|
|
|
|
const auto res = detail::find_not_of<Traits>(rbegin() + pos, rend(), s, n);
|
|
|
|
return res == rend() ? npos : curr_size - 1 - detail::distance(rbegin(), res);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
template<typename InputIterator>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
auto
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
read_back(
|
2020-02-21 19:00:54 -05:00
|
|
|
bool overwrite_null,
|
2020-02-14 16:24:44 -05:00
|
|
|
InputIterator first,
|
|
|
|
InputIterator last) ->
|
|
|
|
size_type
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
const auto curr_data = data();
|
|
|
|
auto new_size = size();
|
|
|
|
for (; first != last; ++first)
|
|
|
|
{
|
2020-02-21 19:00:54 -05:00
|
|
|
if (new_size >= max_size())
|
|
|
|
{
|
|
|
|
if (overwrite_null)
|
|
|
|
term();
|
|
|
|
BOOST_STATIC_STRING_THROW(
|
|
|
|
std::length_error{"count > max_size() - size()"});
|
|
|
|
}
|
|
|
|
traits_type::assign(curr_data[new_size++ + (!overwrite_null)], *first);
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
|
|
|
return new_size - size();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
auto
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
replace_unchecked(
|
2020-02-15 17:00:57 -05:00
|
|
|
const_iterator i1,
|
|
|
|
const_iterator i2,
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type n2) ->
|
|
|
|
basic_static_string&
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
const auto curr_data = data();
|
|
|
|
const auto curr_size = size();
|
2020-02-15 17:00:57 -05:00
|
|
|
const std::size_t pos = i1 - curr_data;
|
|
|
|
const std::size_t n1 = i2 - i1;
|
2020-02-01 16:30:23 -05:00
|
|
|
BOOST_STATIC_STRING_THROW_IF(
|
2020-02-15 17:00:57 -05:00
|
|
|
n2 > max_size() ||
|
2020-02-01 16:30:23 -05:00
|
|
|
curr_size - (std::min)(n1, curr_size - pos) >= max_size() - n2,
|
|
|
|
std::length_error{"replaced string exceeds max_size()"});
|
2020-02-15 17:00:57 -05:00
|
|
|
traits_type::move(&curr_data[pos + n2], i2, (end() - i2) + 1);
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::copy(&curr_data[pos], s, n2);
|
2020-02-03 22:34:08 -05:00
|
|
|
this->set_size((curr_size - n1) + n2);
|
2020-02-01 16:30:23 -05:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<std::size_t N, typename CharT, typename Traits>
|
|
|
|
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
|
|
|
auto
|
|
|
|
basic_static_string<N, CharT, Traits>::
|
|
|
|
insert_unchecked(
|
2020-02-15 17:00:57 -05:00
|
|
|
const_iterator pos,
|
2020-02-14 17:21:54 -05:00
|
|
|
const_pointer s,
|
2020-02-14 16:24:44 -05:00
|
|
|
size_type count) ->
|
2020-02-15 17:00:57 -05:00
|
|
|
iterator
|
2020-02-01 16:30:23 -05:00
|
|
|
{
|
|
|
|
const auto curr_data = data();
|
|
|
|
const auto curr_size = size();
|
|
|
|
BOOST_STATIC_STRING_THROW_IF(
|
2020-02-15 17:00:57 -05:00
|
|
|
count > max_size() - curr_size,
|
2020-02-01 16:30:23 -05:00
|
|
|
std::length_error{"count > max_size() - size()"});
|
2020-02-15 17:00:57 -05:00
|
|
|
const std::size_t index = pos - curr_data;
|
|
|
|
traits_type::move(&curr_data[index + count], pos, (end() - pos) + 1);
|
2020-02-14 17:21:54 -05:00
|
|
|
traits_type::copy(&curr_data[index], s, count);
|
2020-02-01 16:30:23 -05:00
|
|
|
this->set_size(curr_size + count);
|
2020-02-15 17:00:57 -05:00
|
|
|
return curr_data + index;
|
2020-02-01 16:30:23 -05:00
|
|
|
}
|
|
|
|
} // static_string
|
|
|
|
} // boost
|
2019-12-16 12:23:46 -05:00
|
|
|
#endif
|
2020-02-01 16:30:23 -05:00
|
|
|
#endif
|