10 #ifndef BOOST_BEAST_STATIC_STRING_HPP 11 #define BOOST_BEAST_STATIC_STRING_HPP 18 #include <initializer_list> 23 #include <type_traits> 43 class Traits = std::char_traits<CharT>>
46 template<std::
size_t,
class,
class>
52 Traits::assign(s_[n_], 0);
74 std::reverse_iterator<iterator>;
76 std::reverse_iterator<const_iterator>;
106 template<std::
size_t M>
111 template<std::
size_t M>
122 template<
class InputIt>
129 template<std::
size_t M>
145 #if BOOST_BEAST_DOXYGEN 148 template<
class T,
class =
typename std::enable_if<
149 std::is_convertible<T, string_view_type>::value>::type>
165 template<std::
size_t M>
183 return assign_char(ch,
184 std::integral_constant<
bool, (N>0)>{});
214 template<std::
size_t M>
222 template<std::
size_t M>
235 return assign(s, Traits::length(s));
239 template<
class InputIt>
241 assign(InputIt first, InputIt last);
247 return assign(init.begin(), init.end());
254 return assign(str.data(), str.size());
264 #if BOOST_BEAST_DOXYGEN 267 typename std::enable_if<std::is_convertible<T,
513 return insert(index, s, Traits::length(s));
519 template<std::
size_t M>
527 template<std::
size_t M>
536 return insert(pos, 1, ch);
542 template<
class InputIt>
543 #if BOOST_BEAST_DOXYGEN 546 typename std::enable_if<
555 return insert(pos, init.begin(), init.end());
561 return insert(index, str.data(), str.size());
565 #if BOOST_BEAST_DOXYGEN 568 typename std::enable_if<
569 std::is_convertible<T const&, string_view_type>::value &&
570 ! std::is_convertible<T const&, CharT const*>::value,
591 Traits::assign(s_[--n_], 0);
601 template<std::
size_t M>
609 template<std::
size_t M>
628 template<
class InputIt>
629 #if BOOST_BEAST_DOXYGEN 632 typename std::enable_if<
633 detail::is_input_iterator<InputIt>::value,
657 typename std::enable_if<
658 std::is_convertible<T const&, string_view_type>::value &&
659 ! std::is_convertible<T const&, CharT const*>::value,
667 template<std::
size_t M>
699 template<std::
size_t M>
703 return detail::lexicographical_compare<CharT, Traits>(
704 &s_[0], n_, &str.s_[0], str.n_);
707 template<std::
size_t M>
712 return detail::lexicographical_compare<CharT, Traits>(
716 template<std::
size_t M>
729 return detail::lexicographical_compare<CharT, Traits>(
730 &s_[0], n_, s, Traits::length(s));
735 CharT
const* s)
const 737 return detail::lexicographical_compare<CharT, Traits>(
738 substr(pos1, count1), s, Traits::length(s));
745 return detail::lexicographical_compare<CharT, Traits>(
746 substr(pos1, count1), s, count2);
752 return detail::lexicographical_compare<CharT, Traits>(
753 &s_[0], n_, str.data(), str.size());
760 return detail::lexicographical_compare<CharT, Traits>(
761 substr(pos1, count1), str);
765 #if BOOST_BEAST_DOXYGEN 768 typename std::enable_if<
769 std::is_convertible<T const&, string_view_type>::value &&
770 ! std::is_convertible<T const&, CharT const*>::value,
802 resize(std::size_t n, CharT c);
809 template<std::
size_t M>
819 assign_char(CharT ch, std::true_type);
822 assign_char(CharT ch, std::false_type);
832 template<std::
size_t N, std::
size_t M,
class CharT,
class Traits>
838 template<std::
size_t N,
class CharT,
class Traits>
843 template<std::
size_t N,
class CharT,
class Traits>
848 template<std::
size_t N,
class CharT,
class Traits>
851 CharT
const* rhs) =
delete;
853 template<std::
size_t N,
class CharT,
class Traits>
862 template<std::size_t N, std::size_t M,
863 class CharT,
class Traits>
872 template<std::size_t N, std::size_t M,
873 class CharT,
class Traits>
882 template<std::size_t N, std::size_t M,
883 class CharT,
class Traits>
892 template<std::size_t N, std::size_t M,
893 class CharT,
class Traits>
902 template<std::size_t N, std::size_t M,
903 class CharT,
class Traits>
912 template<std::size_t N, std::size_t M,
913 class CharT,
class Traits>
922 template<std::
size_t N,
class CharT,
class Traits>
928 return detail::lexicographical_compare<CharT, Traits>(
929 lhs, Traits::length(lhs),
933 template<std::
size_t N,
class CharT,
class Traits>
939 return detail::lexicographical_compare<CharT, Traits>(
941 rhs, Traits::length(rhs)) == 0;
944 template<std::
size_t N,
class CharT,
class Traits>
950 return detail::lexicographical_compare<CharT, Traits>(
951 lhs, Traits::length(lhs),
955 template<std::
size_t N,
class CharT,
class Traits>
961 return detail::lexicographical_compare<CharT, Traits>(
963 rhs, Traits::length(rhs)) != 0;
966 template<std::
size_t N,
class CharT,
class Traits>
972 return detail::lexicographical_compare<CharT, Traits>(
973 lhs, Traits::length(lhs),
977 template<std::
size_t N,
class CharT,
class Traits>
983 return detail::lexicographical_compare<CharT, Traits>(
985 rhs, Traits::length(rhs)) < 0;
988 template<std::
size_t N,
class CharT,
class Traits>
994 return detail::lexicographical_compare<CharT, Traits>(
995 lhs, Traits::length(lhs),
999 template<std::
size_t N,
class CharT,
class Traits>
1005 return detail::lexicographical_compare<CharT, Traits>(
1007 rhs, Traits::length(rhs)) <= 0;
1010 template<std::
size_t N,
class CharT,
class Traits>
1016 return detail::lexicographical_compare<CharT, Traits>(
1017 lhs, Traits::length(lhs),
1021 template<std::
size_t N,
class CharT,
class Traits>
1027 return detail::lexicographical_compare<CharT, Traits>(
1029 rhs, Traits::length(rhs)) > 0;
1032 template<std::
size_t N,
class CharT,
class Traits>
1038 return detail::lexicographical_compare<CharT, Traits>(
1039 lhs, Traits::length(lhs),
1043 template<std::
size_t N,
class CharT,
class Traits>
1049 return detail::lexicographical_compare<CharT, Traits>(
1051 rhs, Traits::length(rhs)) >= 0;
1058 template<std::
size_t N,
class CharT,
class Traits>
1067 template<std::size_t N, std::size_t M,
1068 class CharT,
class Traits>
1081 template<std::
size_t N,
class CharT,
class Traits>
1082 std::basic_ostream<CharT, Traits>&
1083 operator<<(std::basic_ostream<CharT, Traits>& os,
1086 return os <<
static_cast< 1103 template<
class Integer>
value_type & reference
Definition: static_string.hpp:68
static_string & assign(std::initializer_list< CharT > init)
Assign from initializer list.
Definition: static_string.hpp:245
const_reverse_iterator rend() const
Returns a reverse iterator to the end.
Definition: static_string.hpp:431
static_string< detail::max_digits(sizeof(Integer))> to_static_string(Integer x)
Definition: static_string.ipp:598
void operator+(static_string< N, CharT, Traits >const &lhs, static_string< M, CharT, Traits >const &rhs)=delete
void init(sha1_context &ctx) noexcept
Definition: sha1.hpp:235
std::ptrdiff_t difference_type
Definition: static_string.hpp:66
static_string & erase(size_type index=0, size_type count=npos)
Definition: static_string.ipp:371
Definition: async_result.hpp:20
static_string & operator=(string_view_type sv)
Assign from string_view_type.
Definition: static_string.hpp:196
std::enable_if< std::is_convertible< T const &, string_view_type >::value &&!std::is_convertible< T const &, CharT const * >::value, int >::type compare(size_type pos1, size_type count1, T const &t, size_type pos2, size_type count2=npos) const
Definition: static_string.hpp:773
reference at(size_type pos)
Access specified character with bounds checking.
Definition: static_string.ipp:216
static_string & append(CharT const *s)
Definition: static_string.hpp:622
void swap(static_string &str)
Exchange the contents of this string with another.
Definition: static_string.ipp:487
size_type constexpr max_size() const
Returns the maximum number of characters that can be stored, excluding the null terminator.
Definition: static_string.hpp:470
bool operator>(static_string< N, CharT, Traits > const &lhs, static_string< M, CharT, Traits > const &rhs)
Definition: static_string.hpp:905
bool empty() const
Returns true if the string is empty.
Definition: static_string.hpp:449
void push_back(CharT ch)
Definition: static_string.ipp:408
const_reference operator[](size_type pos) const
Access specified character.
Definition: static_string.hpp:294
static_string & insert(size_type index, CharT const *s)
Definition: static_string.hpp:511
basic_string_view< char, std::char_traits< char > > string_view_type
The type of string_view returned by the interface.
Definition: static_string.hpp:80
static_string & operator=(CharT ch)
Assign from single character.
Definition: static_string.hpp:181
static_string & append(CharT const *s, size_type count)
Definition: static_string.hpp:615
value_type * pointer
Definition: static_string.hpp:67
static_string & operator=(static_string const &str)
Copy assignment.
Definition: static_string.hpp:159
CharT const * data() const
Returns a pointer to the first character of a string.
Definition: static_string.hpp:336
const_reverse_iterator crend() const
Returns a reverse iterator to the end.
Definition: static_string.hpp:438
CharT const * c_str() const
Returns a non-modifiable standard C character array version of the string.
Definition: static_string.hpp:343
static_string & assign(static_string< M, CharT, Traits > const &str)
Assign from another static_string
Definition: static_string.hpp:216
std::integral_constant< bool,!std::is_integral< T >::value > is_input_iterator
Definition: static_string.hpp:26
size_type size() const
Returns the number of characters, excluding the null terminator.
Definition: static_string.hpp:456
static std::size_t constexpr max_size_n
Maximum size of the string excluding the null terminator.
Definition: static_string.hpp:87
void clear()
Clears the contents.
Definition: static_string.ipp:258
std::char_traits< char > traits_type
Definition: static_string.hpp:63
string_view_type substr(size_type pos=0, size_type count=npos) const
Definition: static_string.ipp:438
std::enable_if< detail::is_input_iterator< InputIt >::value, static_string & >::type append(InputIt first, InputIt last)
Definition: static_string.hpp:636
size_type length() const
Returns the number of characters, excluding the null terminator.
Definition: static_string.hpp:463
static_string & operator+=(CharT const *s)
Definition: static_string.hpp:682
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: static_string.hpp:76
size_type constexpr capacity() const
Returns the number of characters that can be held in currently allocated storage. ...
Definition: static_string.hpp:485
bool operator<=(static_string< N, CharT, Traits > const &lhs, static_string< M, CharT, Traits > const &rhs)
Definition: static_string.hpp:895
CharT const & front() const
Accesses the first character.
Definition: static_string.hpp:308
iterator begin()
Returns an iterator to the beginning.
Definition: static_string.hpp:361
static_string & operator=(static_string< M, CharT, Traits > const &str)
Copy assignment.
Definition: static_string.hpp:167
bool operator>=(static_string< N, CharT, Traits > const &lhs, static_string< M, CharT, Traits > const &rhs)
Definition: static_string.hpp:915
void resize(std::size_t n)
Definition: static_string.ipp:461
reverse_iterator rbegin()
Returns a reverse iterator to the beginning.
Definition: static_string.hpp:403
void reserve(std::size_t n)
Definition: static_string.ipp:244
static_string & append(size_type count, CharT ch)
Definition: static_string.hpp:595
int lexicographical_compare(CharT const *s1, std::size_t n1, CharT const *s2, std::size_t n2)
Definition: static_string.hpp:30
static_string & operator+=(string_view_type const &str)
Definition: static_string.hpp:694
value_type const * const_pointer
Definition: static_string.hpp:69
const_reverse_iterator crbegin() const
Returns a reverse iterator to the beginning.
Definition: static_string.hpp:417
static_string & assign(CharT const *s)
Assign a null terminated string.
Definition: static_string.hpp:233
void pop_back()
Definition: static_string.hpp:589
boost::basic_string_ref< CharT, Traits > basic_string_view
The type of basic string view used by the library.
Definition: string.hpp:41
int compare(size_type pos1, size_type count1, string_view_type str) const
Definition: static_string.hpp:757
CharT & front()
Accesses the first character.
Definition: static_string.hpp:301
std::enable_if< std::is_convertible< T const &, string_view_type >::value &&!std::is_convertible< T const &, CharT const * >::value, static_string & >::type append(T const &t, size_type pos, size_type count=npos)
Definition: static_string.hpp:661
static_string & operator=(CharT const *s)
Assign from null-terminated string.
Definition: static_string.hpp:174
iterator insert(const_iterator pos, CharT ch)
Definition: static_string.hpp:534
int compare(static_string< M, CharT, Traits > const &str) const
Definition: static_string.hpp:701
const_reverse_iterator rbegin() const
Returns a reverse iterator to the beginning.
Definition: static_string.hpp:410
std::size_t size_type
Definition: static_string.hpp:65
CharT & back()
Accesses the last character.
Definition: static_string.hpp:315
static_string & assign(string_view_type str)
Assign from string_view_type.
Definition: static_string.hpp:252
static_string & operator+=(std::initializer_list< CharT > init)
Definition: static_string.hpp:688
bool operator<(static_string< N, CharT, Traits > const &lhs, static_string< M, CharT, Traits > const &rhs)
Definition: static_string.hpp:885
int compare(size_type pos1, size_type count1, CharT const *s) const
Definition: static_string.hpp:734
int compare(size_type pos1, size_type count1, CharT const *s, size_type count2) const
Definition: static_string.hpp:742
static_string & insert(size_type index, size_type count, CharT ch)
Definition: static_string.ipp:267
Definition: static_string.hpp:44
static_string & operator+=(static_string< M, CharT, Traits > const &str)
Definition: static_string.hpp:669
iterator end()
Returns an iterator to the end.
Definition: static_string.hpp:382
static constexpr size_type npos
A special index.
Definition: static_string.hpp:90
typename std::char_traits< char >::char_type value_type
Definition: static_string.hpp:64
static_string & append(string_view_type sv)
Definition: static_string.hpp:650
int compare(size_type pos1, size_type count1, static_string< M, CharT, Traits > const &str) const
Definition: static_string.hpp:709
void shrink_to_fit()
Definition: static_string.hpp:495
reverse_iterator rend()
Returns a reverse iterator to the end.
Definition: static_string.hpp:424
static_string & insert(size_type index, static_string< M, CharT, Traits > const &str)
Definition: static_string.hpp:521
static_string & assign(size_type count, CharT ch)
Assign count copies of ch.
Definition: static_string.ipp:123
size_type copy(CharT *dest, size_type count, size_type pos=0) const
Copy a substring (pos, pos+count) to character string pointed to by dest.
Definition: static_string.ipp:450
static_string & append(static_string< M, CharT, Traits > const &str)
Definition: static_string.hpp:603
value_type const & const_reference
Definition: static_string.hpp:70
bool operator!=(static_string< N, CharT, Traits > const &lhs, static_string< M, CharT, Traits > const &rhs)
Definition: static_string.hpp:875
reference operator[](size_type pos)
Access specified character.
Definition: static_string.hpp:287
const_iterator end() const
Returns an iterator to the end.
Definition: static_string.hpp:389
iterator insert(const_iterator pos, std::initializer_list< CharT > init)
Definition: static_string.hpp:553
CharT * data()
Returns a pointer to the first character of a string.
Definition: static_string.hpp:329
const_iterator begin() const
Returns an iterator to the beginning.
Definition: static_string.hpp:368
static_string()
Default constructor (empty string).
Definition: static_string.ipp:26
std::reverse_iterator< iterator > reverse_iterator
Definition: static_string.hpp:74
bool operator==(static_string< N, CharT, Traits > const &lhs, static_string< M, CharT, Traits > const &rhs)
Definition: static_string.hpp:865
static_string & insert(size_type index, string_view_type str)
Definition: static_string.hpp:559
int compare(string_view_type str) const
Definition: static_string.hpp:750
static_string & operator+=(CharT ch)
Definition: static_string.hpp:675
value_type const * const_iterator
Definition: static_string.hpp:72
int compare(CharT const *s) const
Definition: static_string.hpp:727
value_type * iterator
Definition: static_string.hpp:71
const_iterator cbegin() const
Returns an iterator to the beginning.
Definition: static_string.hpp:375
int compare(size_type pos1, size_type count1, static_string< M, CharT, Traits > const &str, size_type pos2, size_type count2=npos) const
Definition: static_string.hpp:718
static_string & append(std::initializer_list< CharT > init)
Definition: static_string.hpp:643
static_string & operator=(std::initializer_list< CharT > init)
Assign from initializer list.
Definition: static_string.hpp:189
const_iterator cend() const
Returns an iterator to the end.
Definition: static_string.hpp:396
CharT const & back() const
Accesses the last character.
Definition: static_string.hpp:322