ゴミ箱
static_string.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // Official repository: https://github.com/boostorg/beast
8 //
9 
10 #ifndef BOOST_BEAST_STATIC_STRING_HPP
11 #define BOOST_BEAST_STATIC_STRING_HPP
12 
13 #include <boost/beast/config.hpp>
16 #include <algorithm>
17 #include <cstdint>
18 #include <initializer_list>
19 #include <iterator>
20 #include <ostream>
21 #include <stdexcept>
22 #include <string>
23 #include <type_traits>
24 
25 namespace boost {
26 namespace beast {
27 
40 template<
41  std::size_t N,
42  class CharT = char,
43  class Traits = std::char_traits<CharT>>
45 {
46  template<std::size_t, class, class>
47  friend class static_string;
48 
49  void
50  term()
51  {
52  Traits::assign(s_[n_], 0);
53  }
54 
55  std::size_t n_;
56  CharT s_[N+1];
57 
58 public:
59  //
60  // Member types
61  //
62 
63  using traits_type = Traits;
64  using value_type = typename Traits::char_type;
65  using size_type = std::size_t;
66  using difference_type = std::ptrdiff_t;
67  using pointer = value_type*;
69  using const_pointer = value_type const*;
70  using const_reference = value_type const&;
71  using iterator = value_type*;
72  using const_iterator = value_type const*;
73  using reverse_iterator =
74  std::reverse_iterator<iterator>;
76  std::reverse_iterator<const_iterator>;
77 
79  using string_view_type =
81 
82  //
83  // Constants
84  //
85 
87  static std::size_t constexpr max_size_n = N;
88 
90  static constexpr size_type npos = size_type(-1);
91 
92  //
93  // (constructor)
94  //
95 
97  static_string();
98 
103  static_string(size_type count, CharT ch);
104 
106  template<std::size_t M>
108  size_type pos);
109 
111  template<std::size_t M>
113  size_type pos, size_type count);
114 
116  static_string(CharT const* s, size_type count);
117 
119  static_string(CharT const* s);
120 
122  template<class InputIt>
123  static_string(InputIt first, InputIt last);
124 
126  static_string(static_string const& other);
127 
129  template<std::size_t M>
131 
133  static_string(std::initializer_list<CharT> init);
134 
136  explicit
138 
145 #if BOOST_BEAST_DOXYGEN
146  template<class T>
147 #else
148  template<class T, class = typename std::enable_if<
149  std::is_convertible<T, string_view_type>::value>::type>
150 #endif
151  static_string(T const& t, size_type pos, size_type n);
152 
153  //
154  // (assignment)
155  //
156 
160  {
161  return assign(str);
162  }
163 
165  template<std::size_t M>
168  {
169  return assign(str);
170  }
171 
174  operator=(CharT const* s)
175  {
176  return assign(s);
177  }
178 
181  operator=(CharT ch)
182  {
183  return assign_char(ch,
184  std::integral_constant<bool, (N>0)>{});
185  }
186 
189  operator=(std::initializer_list<CharT> init)
190  {
191  return assign(init);
192  }
193 
197  {
198  return assign(sv);
199  }
200 
203  assign(size_type count, CharT ch);
204 
207  assign(static_string const& str);
208 
209  // VFALCO NOTE this could come in two flavors,
210  // N>M and N<M, and skip the exception
211  // check when N>M
212 
214  template<std::size_t M>
217  {
218  return assign(str.data(), str.size());
219  }
220 
222  template<std::size_t M>
225  size_type pos, size_type count = npos);
226 
229  assign(CharT const* s, size_type count);
230 
233  assign(CharT const* s)
234  {
235  return assign(s, Traits::length(s));
236  }
237 
239  template<class InputIt>
241  assign(InputIt first, InputIt last);
242 
245  assign(std::initializer_list<CharT> init)
246  {
247  return assign(init.begin(), init.end());
248  }
249 
253  {
254  return assign(str.data(), str.size());
255  }
256 
263  template<class T>
264 #if BOOST_BEAST_DOXYGEN
266 #else
267  typename std::enable_if<std::is_convertible<T,
268  string_view_type>::value, static_string&>::type
269 #endif
270  assign(T const& t,
271  size_type pos, size_type count = npos);
272 
273  //
274  // Element access
275  //
276 
278  reference
279  at(size_type pos);
280 
283  at(size_type pos) const;
284 
286  reference
288  {
289  return s_[pos];
290  }
291 
295  {
296  return s_[pos];
297  }
298 
300  CharT&
302  {
303  return s_[0];
304  }
305 
307  CharT const&
308  front() const
309  {
310  return s_[0];
311  }
312 
314  CharT&
316  {
317  return s_[n_-1];
318  }
319 
321  CharT const&
322  back() const
323  {
324  return s_[n_-1];
325  }
326 
328  CharT*
330  {
331  return &s_[0];
332  }
333 
335  CharT const*
336  data() const
337  {
338  return &s_[0];
339  }
340 
342  CharT const*
343  c_str() const
344  {
345  return data();
346  }
347 
349  operator string_view_type() const
350  {
351  return basic_string_view<
352  CharT, Traits>{data(), size()};
353  }
354 
355  //
356  // Iterators
357  //
358 
360  iterator
362  {
363  return &s_[0];
364  }
365 
368  begin() const
369  {
370  return &s_[0];
371  }
372 
375  cbegin() const
376  {
377  return &s_[0];
378  }
379 
381  iterator
382  end()
383  {
384  return &s_[n_];
385  }
386 
389  end() const
390  {
391  return &s_[n_];
392  }
393 
396  cend() const
397  {
398  return &s_[n_];
399  }
400 
404  {
405  return reverse_iterator{end()};
406  }
407 
410  rbegin() const
411  {
412  return const_reverse_iterator{cend()};
413  }
414 
417  crbegin() const
418  {
419  return const_reverse_iterator{cend()};
420  }
421 
425  {
426  return reverse_iterator{begin()};
427  }
428 
431  rend() const
432  {
433  return const_reverse_iterator{cbegin()};
434  }
435 
438  crend() const
439  {
440  return const_reverse_iterator{cbegin()};
441  }
442 
443  //
444  // Capacity
445  //
446 
448  bool
449  empty() const
450  {
451  return n_ == 0;
452  }
453 
455  size_type
456  size() const
457  {
458  return n_;
459  }
460 
462  size_type
463  length() const
464  {
465  return size();
466  }
467 
469  size_type constexpr
470  max_size() const
471  {
472  return N;
473  }
474 
480  void
481  reserve(std::size_t n);
482 
484  size_type constexpr
485  capacity() const
486  {
487  return max_size();
488  }
489 
494  void
496  {
497  }
498 
499  //
500  // Operations
501  //
502 
504  void
505  clear();
506 
508  insert(size_type index, size_type count, CharT ch);
509 
511  insert(size_type index, CharT const* s)
512  {
513  return insert(index, s, Traits::length(s));
514  }
515 
517  insert(size_type index, CharT const* s, size_type count);
518 
519  template<std::size_t M>
523  {
524  return insert(index, str.data(), str.size());
525  }
526 
527  template<std::size_t M>
529  insert(size_type index,
531  size_type index_str, size_type count = npos);
532 
533  iterator
534  insert(const_iterator pos, CharT ch)
535  {
536  return insert(pos, 1, ch);
537  }
538 
539  iterator
540  insert(const_iterator pos, size_type count, CharT ch);
541 
542  template<class InputIt>
543 #if BOOST_BEAST_DOXYGEN
544  iterator
545 #else
546  typename std::enable_if<
548  iterator>::type
549 #endif
550  insert(const_iterator pos, InputIt first, InputIt last);
551 
552  iterator
553  insert(const_iterator pos, std::initializer_list<CharT> init)
554  {
555  return insert(pos, init.begin(), init.end());
556  }
557 
560  {
561  return insert(index, str.data(), str.size());
562  }
563 
564  template<class T>
565 #if BOOST_BEAST_DOXYGEN
567 #else
568  typename std::enable_if<
569  std::is_convertible<T const&, string_view_type>::value &&
570  ! std::is_convertible<T const&, CharT const*>::value,
571  static_string&>::type
572 #endif
573  insert(size_type index, T const& t,
574  size_type index_str, size_type count = npos);
575 
577  erase(size_type index = 0, size_type count = npos);
578 
579  iterator
580  erase(const_iterator pos);
581 
582  iterator
583  erase(const_iterator first, const_iterator last);
584 
585  void
586  push_back(CharT ch);
587 
588  void
590  {
591  Traits::assign(s_[--n_], 0);
592  }
593 
595  append(size_type count, CharT ch)
596  {
597  insert(end(), count, ch);
598  return *this;
599  }
600 
601  template<std::size_t M>
604  {
605  insert(size(), str);
606  return *this;
607  }
608 
609  template<std::size_t M>
612  size_type pos, size_type count = npos);
613 
615  append(CharT const* s, size_type count)
616  {
617  insert(size(), s, count);
618  return *this;
619  }
620 
622  append(CharT const* s)
623  {
624  insert(size(), s);
625  return *this;
626  }
627 
628  template<class InputIt>
629 #if BOOST_BEAST_DOXYGEN
631 #else
632  typename std::enable_if<
633  detail::is_input_iterator<InputIt>::value,
634  static_string&>::type
635 #endif
636  append(InputIt first, InputIt last)
637  {
638  insert(end(), first, last);
639  return *this;
640  }
641 
643  append(std::initializer_list<CharT> init)
644  {
645  insert(end(), init);
646  return *this;
647  }
648 
651  {
652  insert(size(), sv);
653  return *this;
654  }
655 
656  template<class T>
657  typename std::enable_if<
658  std::is_convertible<T const&, string_view_type>::value &&
659  ! std::is_convertible<T const&, CharT const*>::value,
660  static_string&>::type
661  append(T const& t, size_type pos, size_type count = npos)
662  {
663  insert(size(), t, pos, count);
664  return *this;
665  }
666 
667  template<std::size_t M>
670  {
671  return append(str.data(), str.size());
672  }
673 
675  operator+=(CharT ch)
676  {
677  push_back(ch);
678  return *this;
679  }
680 
682  operator+=(CharT const* s)
683  {
684  return append(s);
685  }
686 
688  operator+=(std::initializer_list<CharT> init)
689  {
690  return append(init);
691  }
692 
695  {
696  return append(str);
697  }
698 
699  template<std::size_t M>
700  int
702  {
703  return detail::lexicographical_compare<CharT, Traits>(
704  &s_[0], n_, &str.s_[0], str.n_);
705  }
706 
707  template<std::size_t M>
708  int
710  static_string<M, CharT, Traits> const& str) const
711  {
712  return detail::lexicographical_compare<CharT, Traits>(
713  substr(pos1, count1), str.data(), str.size());
714  }
715 
716  template<std::size_t M>
717  int
720  size_type pos2, size_type count2 = npos) const
721  {
723  substr(pos1, count1), str.substr(pos2, count2));
724  }
725 
726  int
727  compare(CharT const* s) const
728  {
729  return detail::lexicographical_compare<CharT, Traits>(
730  &s_[0], n_, s, Traits::length(s));
731  }
732 
733  int
735  CharT const* s) const
736  {
737  return detail::lexicographical_compare<CharT, Traits>(
738  substr(pos1, count1), s, Traits::length(s));
739  }
740 
741  int
743  CharT const*s, size_type count2) const
744  {
745  return detail::lexicographical_compare<CharT, Traits>(
746  substr(pos1, count1), s, count2);
747  }
748 
749  int
751  {
752  return detail::lexicographical_compare<CharT, Traits>(
753  &s_[0], n_, str.data(), str.size());
754  }
755 
756  int
758  string_view_type str) const
759  {
760  return detail::lexicographical_compare<CharT, Traits>(
761  substr(pos1, count1), str);
762  }
763 
764  template<class T>
765 #if BOOST_BEAST_DOXYGEN
766  int
767 #else
768  typename std::enable_if<
769  std::is_convertible<T const&, string_view_type>::value &&
770  ! std::is_convertible<T const&, CharT const*>::value,
771  int>::type
772 #endif
774  T const& t, size_type pos2,
775  size_type count2 = npos) const
776  {
777  return compare(pos1, count1,
778  string_view_type(t).substr(pos2, count2));
779  }
780 
782  substr(size_type pos = 0, size_type count = npos) const;
783 
785  size_type
786  copy(CharT* dest, size_type count, size_type pos = 0) const;
787 
793  void
794  resize(std::size_t n);
795 
801  void
802  resize(std::size_t n, CharT c);
803 
805  void
806  swap(static_string& str);
807 
809  template<std::size_t M>
810  void
812 
813  //
814  // Search
815  //
816 
817 private:
819  assign_char(CharT ch, std::true_type);
820 
822  assign_char(CharT ch, std::false_type);
823 };
824 
825 //
826 // Disallowed operations
827 //
828 
829 // These operations are explicitly deleted since
830 // there is no reasonable implementation possible.
831 
832 template<std::size_t N, std::size_t M, class CharT, class Traits>
833 void
834 operator+(
836  static_string<M, CharT, Traits>const& rhs) = delete;
837 
838 template<std::size_t N, class CharT, class Traits>
839 void
840 operator+(CharT const* lhs,
841  static_string<N, CharT, Traits>const& rhs) = delete;
842 
843 template<std::size_t N, class CharT, class Traits>
844 void
845 operator+(CharT lhs,
846  static_string<N, CharT, Traits> const& rhs) = delete;
847 
848 template<std::size_t N, class CharT, class Traits>
849 void
851  CharT const* rhs) = delete;
852 
853 template<std::size_t N, class CharT, class Traits>
854 void
856  CharT rhs) = delete;
857 
858 //
859 // Non-member functions
860 //
861 
862 template<std::size_t N, std::size_t M,
863  class CharT, class Traits>
864 bool
868 {
869  return lhs.compare(rhs) == 0;
870 }
871 
872 template<std::size_t N, std::size_t M,
873  class CharT, class Traits>
874 bool
878 {
879  return lhs.compare(rhs) != 0;
880 }
881 
882 template<std::size_t N, std::size_t M,
883  class CharT, class Traits>
884 bool
888 {
889  return lhs.compare(rhs) < 0;
890 }
891 
892 template<std::size_t N, std::size_t M,
893  class CharT, class Traits>
894 bool
898 {
899  return lhs.compare(rhs) <= 0;
900 }
901 
902 template<std::size_t N, std::size_t M,
903  class CharT, class Traits>
904 bool
908 {
909  return lhs.compare(rhs) > 0;
910 }
911 
912 template<std::size_t N, std::size_t M,
913  class CharT, class Traits>
914 bool
918 {
919  return lhs.compare(rhs) >= 0;
920 }
921 
922 template<std::size_t N, class CharT, class Traits>
923 bool
925  CharT const* lhs,
927 {
928  return detail::lexicographical_compare<CharT, Traits>(
929  lhs, Traits::length(lhs),
930  rhs.data(), rhs.size()) == 0;
931 }
932 
933 template<std::size_t N, class CharT, class Traits>
934 bool
937  CharT const* rhs)
938 {
939  return detail::lexicographical_compare<CharT, Traits>(
940  lhs.data(), lhs.size(),
941  rhs, Traits::length(rhs)) == 0;
942 }
943 
944 template<std::size_t N, class CharT, class Traits>
945 bool
947  CharT const* lhs,
949 {
950  return detail::lexicographical_compare<CharT, Traits>(
951  lhs, Traits::length(lhs),
952  rhs.data(), rhs.size()) != 0;
953 }
954 
955 template<std::size_t N, class CharT, class Traits>
956 bool
959  CharT const* rhs)
960 {
961  return detail::lexicographical_compare<CharT, Traits>(
962  lhs.data(), lhs.size(),
963  rhs, Traits::length(rhs)) != 0;
964 }
965 
966 template<std::size_t N, class CharT, class Traits>
967 bool
969  CharT const* lhs,
971 {
972  return detail::lexicographical_compare<CharT, Traits>(
973  lhs, Traits::length(lhs),
974  rhs.data(), rhs.size()) < 0;
975 }
976 
977 template<std::size_t N, class CharT, class Traits>
978 bool
981  CharT const* rhs)
982 {
983  return detail::lexicographical_compare<CharT, Traits>(
984  lhs.data(), lhs.size(),
985  rhs, Traits::length(rhs)) < 0;
986 }
987 
988 template<std::size_t N, class CharT, class Traits>
989 bool
991  CharT const* lhs,
993 {
994  return detail::lexicographical_compare<CharT, Traits>(
995  lhs, Traits::length(lhs),
996  rhs.data(), rhs.size()) <= 0;
997 }
998 
999 template<std::size_t N, class CharT, class Traits>
1000 bool
1003  CharT const* rhs)
1004 {
1005  return detail::lexicographical_compare<CharT, Traits>(
1006  lhs.data(), lhs.size(),
1007  rhs, Traits::length(rhs)) <= 0;
1008 }
1009 
1010 template<std::size_t N, class CharT, class Traits>
1011 bool
1013  CharT const* lhs,
1015 {
1016  return detail::lexicographical_compare<CharT, Traits>(
1017  lhs, Traits::length(lhs),
1018  rhs.data(), rhs.size()) > 0;
1019 }
1020 
1021 template<std::size_t N, class CharT, class Traits>
1022 bool
1025  CharT const* rhs)
1026 {
1027  return detail::lexicographical_compare<CharT, Traits>(
1028  lhs.data(), lhs.size(),
1029  rhs, Traits::length(rhs)) > 0;
1030 }
1031 
1032 template<std::size_t N, class CharT, class Traits>
1033 bool
1035  CharT const* lhs,
1037 {
1038  return detail::lexicographical_compare<CharT, Traits>(
1039  lhs, Traits::length(lhs),
1040  rhs.data(), rhs.size()) >= 0;
1041 }
1042 
1043 template<std::size_t N, class CharT, class Traits>
1044 bool
1047  CharT const* rhs)
1048 {
1049  return detail::lexicographical_compare<CharT, Traits>(
1050  lhs.data(), lhs.size(),
1051  rhs, Traits::length(rhs)) >= 0;
1052 }
1053 
1054 //
1055 // swap
1056 //
1057 
1058 template<std::size_t N, class CharT, class Traits>
1059 void
1063 {
1064  lhs.swap(rhs);
1065 }
1066 
1067 template<std::size_t N, std::size_t M,
1068  class CharT, class Traits>
1069 void
1073 {
1074  lhs.swap(rhs);
1075 }
1076 
1077 //
1078 // Input/Output
1079 //
1080 
1081 template<std::size_t N, class CharT, class Traits>
1082 std::basic_ostream<CharT, Traits>&
1083 operator<<(std::basic_ostream<CharT, Traits>& os,
1085 {
1086  return os << static_cast<
1088 }
1089 
1090 //
1091 // Numeric conversions
1092 //
1093 
1103 template<class Integer>
1105 to_static_string(Integer x);
1106 
1107 } // beast
1108 } // boost
1109 
1111 
1112 #endif
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