Backport
string_view.hpp
Go to the documentation of this file.
1 
7 /*
8  The MIT License (MIT)
9 
10  Copyright (c) 2016 Matthew Rodusek All rights reserved.
11 
12  Permission is hereby granted, free of charge, to any person obtaining a copy
13  of this software and associated documentation files (the "Software"), to deal
14  in the Software without restriction, including without limitation the rights
15  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16  copies of the Software, and to permit persons to whom the Software is
17  furnished to do so, subject to the following conditions:
18 
19  The above copyright notice and this permission notice shall be included in
20  all copies or substantial portions of the Software.
21 
22  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28  SOFTWARE.
29 */
30 #ifndef BPSTD_STRING_VIEW_HPP
31 #define BPSTD_STRING_VIEW_HPP
32 
33 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
34 # pragma once
35 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
36 
37 #include "detail/config.hpp" // BPSTD_CPP14_CONSTEXPR
38 
39 #include <algorithm> // std::min, std::max
40 #include <string> // std::char_traits
41 #include <ostream> // std::basic_ostream
42 #include <cstddef> // std::size_t
43 #include <memory> // std::allocator
44 #include <stdexcept> // std::out_of_range
45 #include <iterator> // std::reverse_iterator
46 #include <ios> // std::streamsize
47 
48 BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE
49 
50 namespace bpstd { // back-port std
51 
60  template <typename CharT, typename Traits = std::char_traits<CharT>>
62  {
63  //--------------------------------------------------------------------------
64  // Public Member Types
65  //--------------------------------------------------------------------------
66  public:
67 
68  using char_type = CharT;
69  using traits_type = Traits;
70  using size_type = std::size_t;
71 
72  using value_type = CharT;
73  using reference = value_type&;
74  using const_reference = const value_type&;
75  using pointer = value_type*;
76  using const_pointer = const value_type*;
77 
78  using iterator = const CharT*;
79  using const_iterator = const CharT*;
80  using reverse_iterator = std::reverse_iterator<iterator>;
81  using const_reverse_iterator = std::reverse_iterator<const_iterator>;
82 
83  //--------------------------------------------------------------------------
84  // Public Members
85  //--------------------------------------------------------------------------
86  public:
87 
88  static constexpr size_type npos = size_type(-1);
89 
90  //--------------------------------------------------------------------------
91  // Constructors
92  //--------------------------------------------------------------------------
93  public:
94 
96  constexpr basic_string_view() noexcept;
97 
101  constexpr basic_string_view(const basic_string_view& other) noexcept = default;
102 
106  constexpr basic_string_view(basic_string_view&& other) noexcept = default;
107 
111  template <typename Allocator>
112  // cppcheck-suppress noExplicitConstructor
113  basic_string_view(const std::basic_string<CharT,Traits,Allocator>& str) noexcept;
114 
118  // cppcheck-suppress noExplicitConstructor
119  constexpr basic_string_view(const char_type* str) noexcept;
120 
125  constexpr basic_string_view(const char_type* str, size_type count) noexcept;
126 
127  //--------------------------------------------------------------------------
128  // Assignment
129  //--------------------------------------------------------------------------
130  public:
131 
136  basic_string_view& operator=(const basic_string_view& view) = default;
137 
138  //--------------------------------------------------------------------------
139  // Capacity
140  //--------------------------------------------------------------------------
141  public:
142 
147  constexpr size_type size() const noexcept;
148  constexpr size_type length() const noexcept;
150 
154  constexpr size_type max_size() const noexcept;
155 
160  constexpr bool empty() const noexcept;
161 
162  //--------------------------------------------------------------------------
163  // Element Access
164  //--------------------------------------------------------------------------
165  public:
166 
172  constexpr const char_type* data() const noexcept;
173 
178  constexpr const_reference operator[](size_type pos) const noexcept;
179 
184  constexpr const_reference at(size_type pos) const;
185 
191  constexpr const_reference front() const noexcept;
192 
198  constexpr const_reference back() const noexcept;
199 
200  //--------------------------------------------------------------------------
201  // Modifiers
202  //--------------------------------------------------------------------------
203  public:
204 
210  BPSTD_CPP14_CONSTEXPR void remove_prefix(size_type n) noexcept;
211 
217  BPSTD_CPP14_CONSTEXPR void remove_suffix(size_type n) noexcept;
218 
222  BPSTD_CPP14_CONSTEXPR void swap(basic_string_view& v) noexcept;
223 
224  //--------------------------------------------------------------------------
225  // Conversions
226  //--------------------------------------------------------------------------
227  public:
228 
234  template <typename Allocator>
235  explicit constexpr operator std::basic_string<CharT, Traits, Allocator>() const;
236 
237  //--------------------------------------------------------------------------
238  // Operations
239  //--------------------------------------------------------------------------
240  public:
241 
248  BPSTD_CPP14_CONSTEXPR size_type copy(char_type* dest,
249  size_type count = npos,
250  size_type pos = 0) const;
251 
257  BPSTD_CPP14_CONSTEXPR basic_string_view substr(size_t pos = 0,
258  size_t len = npos) const;
259 
260  //--------------------------------------------------------------------------
261 
268  BPSTD_CPP14_CONSTEXPR int compare(basic_string_view v) const noexcept;
269 
278  BPSTD_CPP14_CONSTEXPR int compare(size_type pos, size_type count, basic_string_view v) const;
279 
290  BPSTD_CPP14_CONSTEXPR int compare(size_type pos1,
291  size_type count1,
293  size_type pos2,
294  size_type count2) const;
295 
302  BPSTD_CPP14_CONSTEXPR int compare(const char_type* s) const;
303 
312  BPSTD_CPP14_CONSTEXPR int compare(size_type pos,
313  size_type count,
314  const char_type* s) const;
315 
325  BPSTD_CPP14_CONSTEXPR int compare(size_type pos,
326  size_type count1,
327  const char_type* s,
328  size_type count2) const;
329 
330  //--------------------------------------------------------------------------
331 
332  BPSTD_CPP14_CONSTEXPR size_type find(basic_string_view v,
333  size_type pos = 0) const;
334  BPSTD_CPP14_CONSTEXPR size_type find(char_type c,
335  size_type pos = 0) const;
336  BPSTD_CPP14_CONSTEXPR size_type find(const char_type* s,
337  size_type pos,
338  size_type count) const;
339  BPSTD_CPP14_CONSTEXPR size_type find(const char_type* s,
340  size_type pos = 0) const;
341 
342  //--------------------------------------------------------------------------
343 
344  BPSTD_CPP14_CONSTEXPR size_type rfind(basic_string_view v,
345  size_type pos = npos) const;
346  BPSTD_CPP14_CONSTEXPR size_type rfind(char_type c,
347  size_type pos = npos) const;
348  BPSTD_CPP14_CONSTEXPR size_type rfind(const char_type* s,
349  size_type pos,
350  size_type count) const;
351  BPSTD_CPP14_CONSTEXPR size_type rfind(const char_type* s,
352  size_type pos = npos) const;
353 
354  //--------------------------------------------------------------------------
355 
356  BPSTD_CPP14_CONSTEXPR size_type find_first_of(basic_string_view v,
357  size_type pos = 0) const;
358  BPSTD_CPP14_CONSTEXPR size_type find_first_of(char_type c,
359  size_type pos = 0) const;
360  BPSTD_CPP14_CONSTEXPR size_type find_first_of(const char_type* s,
361  size_type pos,
362  size_type count) const;
363  BPSTD_CPP14_CONSTEXPR size_type find_first_of(const char_type* s,
364  size_type pos = 0) const;
365 
366  //--------------------------------------------------------------------------
367 
368  BPSTD_CPP14_CONSTEXPR size_type find_last_of(basic_string_view v,
369  size_type pos = npos) const;
370  BPSTD_CPP14_CONSTEXPR size_type find_last_of(char_type c,
371  size_type pos = npos) const;
372  BPSTD_CPP14_CONSTEXPR size_type find_last_of(const char_type* s,
373  size_type pos, size_type count) const;
374  BPSTD_CPP14_CONSTEXPR size_type find_last_of(const char_type* s,
375  size_type pos = npos) const;
376 
377  //--------------------------------------------------------------------------
378 
379  BPSTD_CPP14_CONSTEXPR size_type find_first_not_of(basic_string_view v,
380  size_type pos = 0) const;
381  BPSTD_CPP14_CONSTEXPR size_type find_first_not_of(char_type c,
382  size_type pos = 0) const;
383  BPSTD_CPP14_CONSTEXPR size_type find_first_not_of(const char_type* s,
384  size_type pos,
385  size_type count) const;
386  BPSTD_CPP14_CONSTEXPR size_type find_first_not_of(const char_type* s,
387  size_type pos = 0) const;
388 
389  //--------------------------------------------------------------------------
390 
391  BPSTD_CPP14_CONSTEXPR size_type find_last_not_of(basic_string_view v,
392  size_type pos = npos) const;
393  BPSTD_CPP14_CONSTEXPR size_type find_last_not_of(char_type c,
394  size_type pos = npos) const;
395  BPSTD_CPP14_CONSTEXPR size_type find_last_not_of(const char_type* s,
396  size_type pos,
397  size_type count) const;
398  BPSTD_CPP14_CONSTEXPR size_type find_last_not_of(const char_type* s,
399  size_type pos = npos) const;
400 
401  //--------------------------------------------------------------------------
402  // Iterators
403  //--------------------------------------------------------------------------
404  public:
405 
410  BPSTD_CPP14_CONSTEXPR const_iterator begin() const noexcept;
411  BPSTD_CPP14_CONSTEXPR const_iterator cbegin() const noexcept;
413 
418  BPSTD_CPP14_CONSTEXPR const_iterator end() const noexcept;
419  BPSTD_CPP14_CONSTEXPR const_iterator cend() const noexcept;
421 
426  BPSTD_CPP14_CONSTEXPR const_reverse_iterator rbegin() const noexcept;
427  BPSTD_CPP14_CONSTEXPR const_reverse_iterator rend() const noexcept;
429 
434  BPSTD_CPP14_CONSTEXPR const_reverse_iterator crbegin() const noexcept;
435  BPSTD_CPP14_CONSTEXPR const_reverse_iterator crend() const noexcept;
437 
438  //--------------------------------------------------------------------------
439  // Private Member
440  //--------------------------------------------------------------------------
441  private:
442 
443  const char_type* m_str;
444  size_type m_size;
445 
451  static BPSTD_CPP14_CONSTEXPR bool is_one_of(CharT c, basic_string_view str);
452  };
453 
454  template <typename CharT, typename Traits>
455  constexpr typename bpstd::basic_string_view<CharT,Traits>::size_type
457 
458  //----------------------------------------------------------------------------
459  // Public Functions
460  //----------------------------------------------------------------------------
461 
467  template <typename CharT, typename Traits>
468  std::basic_ostream<CharT,Traits>& operator<<(std::basic_ostream<CharT,Traits>& o,
470 
471  template <typename CharT, typename Traits>
473  basic_string_view<CharT,Traits>& rhs) noexcept;
474 
475  //----------------------------------------------------------------------------
476  // Comparison Functions
477  //----------------------------------------------------------------------------
478 
479  template <typename CharT, typename Traits>
480  BPSTD_CPP14_CONSTEXPR bool
481  operator==(const basic_string_view<CharT,Traits>& lhs,
482  const basic_string_view<CharT,Traits>& rhs) noexcept;
483  template <typename CharT, typename Traits>
484  BPSTD_CPP14_CONSTEXPR bool
485  operator!=(const basic_string_view<CharT,Traits>& lhs,
486  const basic_string_view<CharT,Traits>& rhs) noexcept;
487  template <typename CharT, typename Traits>
488  BPSTD_CPP14_CONSTEXPR bool
489  operator<(const basic_string_view<CharT,Traits>& lhs,
490  const basic_string_view<CharT,Traits>& rhs) noexcept;
491  template <typename CharT, typename Traits>
492  BPSTD_CPP14_CONSTEXPR bool
493  operator>(const basic_string_view<CharT,Traits>& lhs,
494  const basic_string_view<CharT,Traits>& rhs) noexcept;
495  template <typename CharT, typename Traits>
496  BPSTD_CPP14_CONSTEXPR bool
497  operator<=(const basic_string_view<CharT,Traits>& lhs,
498  const basic_string_view<CharT,Traits>& rhs) noexcept;
499  template <typename CharT, typename Traits>
500  BPSTD_CPP14_CONSTEXPR bool
501  operator>=(const basic_string_view<CharT,Traits>& lhs,
502  const basic_string_view<CharT,Traits>& rhs) noexcept;
503 
504  //----------------------------------------------------------------------------
505  // Type Aliases
506  //----------------------------------------------------------------------------
507 
512 
513 } // namespace bpstd
514 
515 //==============================================================================
516 // definition : class : basic_string_view
517 //==============================================================================
518 
519 //------------------------------------------------------------------------------
520 // Constructor
521 //------------------------------------------------------------------------------
522 
523 template <typename CharT, typename Traits>
524 inline BPSTD_INLINE_VISIBILITY constexpr
526  noexcept
527  : m_str{nullptr},
528  m_size{0}
529 {
530 
531 }
532 
533 template <typename CharT, typename Traits>
534 template <typename Allocator>
535 inline BPSTD_INLINE_VISIBILITY
537  ::basic_string_view(const std::basic_string<CharT,Traits,Allocator>& str)
538  noexcept
539  : m_str{str.c_str()},
540  m_size{str.size()}
541 {
542 
543 }
544 
545 template <typename CharT, typename Traits>
546 inline BPSTD_INLINE_VISIBILITY constexpr
548  ::basic_string_view(const char_type* str)
549  noexcept
550  : m_str{str},
551  m_size{traits_type::length(str)}
552 {
553 
554 }
555 
556 template <typename CharT, typename Traits>
557 inline BPSTD_INLINE_VISIBILITY constexpr
559  ::basic_string_view(const char_type* str, size_type count)
560  noexcept
561  : m_str{str},
562  m_size{count}
563 {
564 
565 }
566 
567 //------------------------------------------------------------------------------
568 // Capacity
569 //------------------------------------------------------------------------------
570 
571 template <typename CharT, typename Traits>
572 inline BPSTD_INLINE_VISIBILITY constexpr
573 typename bpstd::basic_string_view<CharT,Traits>::size_type
575  const noexcept
576 {
577  return m_size;
578 }
579 
580 template <typename CharT, typename Traits>
581 inline BPSTD_INLINE_VISIBILITY constexpr
582 typename bpstd::basic_string_view<CharT,Traits>::size_type
584  const noexcept
585 {
586  return size();
587 }
588 
589 template <typename CharT, typename Traits>
590 inline BPSTD_INLINE_VISIBILITY constexpr
591 typename bpstd::basic_string_view<CharT,Traits>::size_type
593  const noexcept
594 {
595  return npos - 1;
596 }
597 
598 template <typename CharT, typename Traits>
599 inline BPSTD_INLINE_VISIBILITY constexpr
601  const noexcept
602 {
603  return m_size == 0u;
604 }
605 
606 //------------------------------------------------------------------------------
607 // Element Access
608 //------------------------------------------------------------------------------
609 
610 template <typename CharT, typename Traits>
611 inline BPSTD_INLINE_VISIBILITY constexpr
612 const typename bpstd::basic_string_view<CharT,Traits>::char_type*
614  const noexcept
615 {
616  return m_str;
617 }
618 
619 template <typename CharT, typename Traits>
620 inline BPSTD_INLINE_VISIBILITY constexpr
621 typename bpstd::basic_string_view<CharT,Traits>::const_reference
623  const noexcept
624 {
625  return m_str[pos];
626 }
627 
628 template <typename CharT, typename Traits>
629 inline BPSTD_INLINE_VISIBILITY constexpr
630 typename bpstd::basic_string_view<CharT,Traits>::const_reference
632  const
633 {
634  return (pos < m_size)
635  ? m_str[pos]
636  : (throw std::out_of_range{"Input out of range in basic_string_view::at"}), m_str[pos];
637 }
638 
639 template <typename CharT, typename Traits>
640 inline BPSTD_INLINE_VISIBILITY constexpr
641 typename bpstd::basic_string_view<CharT,Traits>::const_reference
643  const noexcept
644 {
645  return *m_str;
646 }
647 
648 template <typename CharT, typename Traits>
649 inline BPSTD_INLINE_VISIBILITY constexpr
650 typename bpstd::basic_string_view<CharT,Traits>::const_reference
652  const noexcept
653 {
654  return m_str[m_size-1];
655 }
656 
657 //------------------------------------------------------------------------------
658 // Modifiers
659 //------------------------------------------------------------------------------
660 
661 template <typename CharT, typename Traits>
662 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
664  noexcept
665 {
666  m_str += n, m_size -= n;
667 }
668 
669 template <typename CharT, typename Traits>
670 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
672  noexcept
673 {
674  m_size -= n;
675 }
676 
677 template <typename CharT, typename Traits>
678 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
680  noexcept
681 {
682  using std::swap;
683  swap(m_size,v.m_size);
684  swap(m_str,v.m_str);
685 }
686 
687 //------------------------------------------------------------------------------
688 // Conversions
689 //------------------------------------------------------------------------------
690 
691 template <typename CharT, typename Traits>
692 template <class Allocator>
693 inline BPSTD_INLINE_VISIBILITY constexpr
695  std::basic_string<CharT, Traits, Allocator>()
696  const
697 {
698  return std::basic_string<CharT,Traits,Allocator>(m_str, m_size);
699 }
700 
701 //------------------------------------------------------------------------------
702 // String Operations
703 //------------------------------------------------------------------------------
704 
705 template <typename CharT, typename Traits>
706 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
707 typename bpstd::basic_string_view<CharT,Traits>::size_type
709  size_type count,
710  size_type pos)
711  const
712 {
713  if(pos >= m_size) {
714  throw std::out_of_range("Index out of range in basic_string_view::copy");
715  }
716 
717  const auto rcount = std::min(m_size - pos,count+1);
718  auto* const begin = m_str + pos;
719  auto* const end = m_str + pos + rcount;
720  for (auto it = begin; it != end; ++it) {
721  *dest = *it;
722  ++dest;
723  }
724  return rcount;
725 }
726 
727 template <typename CharT, typename Traits>
728 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
731  size_type len)
732  const
733 {
734  const size_type max_length = pos > m_size ? 0 : m_size - pos;
735 
736  if (pos > size()) {
737  throw std::out_of_range("Index out of range in basic_string_view::substr");
738  }
739 
740  return basic_string_view(m_str + pos, std::min(len, max_length) );
741 }
742 
743 //------------------------------------------------------------------------------
744 
745 template <typename CharT, typename Traits>
746 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
747 int
749  const noexcept
750 {
751  const size_type rlen = std::min(m_size,v.m_size);
752  const int compare = Traits::compare(m_str,v.m_str,rlen);
753 
754  if (compare != 0) {
755  return compare;
756  }
757  if (m_size < v.m_size) {
758  return -1;
759  }
760  if (m_size > v.m_size) {
761  return 1;
762  }
763  return 0;
764 }
765 
766 template <typename CharT, typename Traits>
767 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
768 int
770  size_type count,
772  const
773 {
774  return substr(pos,count).compare(v);
775 }
776 
777 template <typename CharT, typename Traits>
778 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
779 int
781  size_type count1,
783  size_type pos2,
784  size_type count2)
785  const
786 {
787  return substr(pos1,count1).compare(v.substr(pos2,count2));
788 }
789 
790 template <typename CharT, typename Traits>
791 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
792 int
794  const
795 {
796  return compare(basic_string_view<CharT,Traits>(s));
797 }
798 
799 template <typename CharT, typename Traits>
800 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
801 int
803  size_type count,
804  const char_type* s)
805  const
806 {
807  return substr(pos, count).compare(basic_string_view<CharT,Traits>(s));
808 }
809 
810 template <typename CharT, typename Traits>
811 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
812 int
814  size_type count1,
815  const char_type* s,
816  size_type count2)
817  const
818 {
819  return substr(pos, count1).compare(basic_string_view<CharT,Traits>(s, count2));
820 }
821 
822 //------------------------------------------------------------------------------
823 
824 template <typename CharT, typename Traits>
825 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
826 typename bpstd::basic_string_view<CharT,Traits>::size_type
828  size_type pos)
829  const
830 {
831  // Can't find a substring if the substring is bigger than this
832  if (pos > size()) {
833  return npos;
834  }
835  if ((pos + v.size()) > size()) {
836  return npos;
837  }
838 
839  const auto offset = pos;
840  const auto increments = size() - v.size();
841 
842  for (auto i = 0u; i <= increments; ++i) {
843  const auto j = i + offset;
844  if (substr(j, v.size()) == v) {
845  return j;
846  }
847  }
848  return npos;
849 }
850 
851 template <typename CharT, typename Traits>
852 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
853 typename bpstd::basic_string_view<CharT,Traits>::size_type
855  size_type pos)
856  const
857 {
858  return find(basic_string_view<CharT,Traits>(&c, 1), pos);
859 }
860 
861 template <typename CharT, typename Traits>
862 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
863 typename bpstd::basic_string_view<CharT,Traits>::size_type
864  bpstd::basic_string_view<CharT,Traits>::find(const char_type* s, size_type pos,
865  size_type count)
866  const
867 {
868  return find(basic_string_view<CharT,Traits>(s, count), pos);
869 }
870 
871 template <typename CharT, typename Traits>
872 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
873 typename bpstd::basic_string_view<CharT,Traits>::size_type
875  size_type pos)
876  const
877 {
878  return find(basic_string_view<CharT,Traits>(s), pos);
879 }
880 
881 //------------------------------------------------------------------------------
882 
883 template <typename CharT, typename Traits>
884 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
885 typename bpstd::basic_string_view<CharT,Traits>::size_type
887  size_type pos)
888  const
889 {
890  if (empty()) {
891  return v.empty() ? 0u : npos;
892  }
893  if (v.empty()) {
894  return std::min(size() - 1, pos);
895  }
896  if (v.size() > size()) {
897  return npos;
898  }
899 
900  auto i = std::min(pos, (size() - v.size()));
901  while (i != npos) {
902  if (substr(i, v.size()) == v) {
903  return i;
904  }
905  --i;
906  }
907 
908  return npos;
909 }
910 
911 template <typename CharT, typename Traits>
912 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
913 typename bpstd::basic_string_view<CharT,Traits>::size_type
915  size_type pos)
916  const
917 {
918  return rfind(basic_string_view<CharT,Traits>(&c, 1), pos);
919 }
920 
921 template <typename CharT, typename Traits>
922 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
923 typename bpstd::basic_string_view<CharT,Traits>::size_type
925  size_type pos,
926  size_type count)
927  const
928 {
929  return rfind(basic_string_view<CharT,Traits>(s, count), pos);
930 }
931 
932 template <typename CharT, typename Traits>
933 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
934 typename bpstd::basic_string_view<CharT,Traits>::size_type
936  size_type pos)
937  const
938 {
939  return rfind(basic_string_view<CharT,Traits>(s), pos);
940 }
941 
942 //------------------------------------------------------------------------------
943 
944 template <typename CharT, typename Traits>
945 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
946 typename bpstd::basic_string_view<CharT,Traits>::size_type
948  size_type pos)
949  const
950 {
951  const auto max_index = size();
952  for (auto i = pos; i < max_index; ++i) {
953  if (is_one_of(m_str[i],v)) {
954  return i;
955  }
956  }
957 
958  return npos;
959 }
960 
961 template <typename CharT, typename Traits>
962 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
963 typename bpstd::basic_string_view<CharT,Traits>::size_type
965  size_type pos)
966  const
967 {
968  return find_first_of(basic_string_view<CharT,Traits>(&c, 1), pos);
969 }
970 
971 template <typename CharT, typename Traits>
972 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
973 typename bpstd::basic_string_view<CharT,Traits>::size_type
975  size_type pos,
976  size_type count)
977  const
978 {
979  return find_first_of(basic_string_view<CharT,Traits>(s, count), pos);
980 }
981 
982 template <typename CharT, typename Traits>
983 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
984 typename bpstd::basic_string_view<CharT,Traits>::size_type
986  size_type pos)
987  const
988 {
989  return find_first_of(basic_string_view<CharT,Traits>(s), pos);
990 }
991 
992 //------------------------------------------------------------------------------
993 
994 template <typename CharT, typename Traits>
995 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
996 typename bpstd::basic_string_view<CharT,Traits>::size_type
998  size_type pos)
999  const
1000 {
1001  if (empty()) {
1002  return npos;
1003  }
1004  const auto max_index = std::min(size() - 1, pos);
1005  for (auto i = 0u; i <= max_index; ++i) {
1006  const auto j = max_index - i;
1007 
1008  if (is_one_of(m_str[j],v)) {
1009  return j;
1010  }
1011  }
1012 
1013  return npos;
1014 }
1015 
1016 template <typename CharT, typename Traits>
1017 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1018 typename bpstd::basic_string_view<CharT,Traits>::size_type
1020  size_type pos)
1021  const
1022 {
1023  return find_last_of(basic_string_view<CharT,Traits>(&c, 1), pos);
1024 }
1025 
1026 template <typename CharT, typename Traits>
1027 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1028 typename bpstd::basic_string_view<CharT,Traits>::size_type
1030  size_type pos,
1031  size_type count)
1032  const
1033 {
1034  return find_last_of(basic_string_view<CharT,Traits>(s, count), pos);
1035 }
1036 
1037 template <typename CharT, typename Traits>
1038 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1039 typename bpstd::basic_string_view<CharT,Traits>::size_type
1041  size_type pos)
1042  const
1043 {
1044  return find_last_of(basic_string_view<CharT,Traits>(s), pos);
1045 }
1046 
1047 //------------------------------------------------------------------------------
1048 
1049 template <typename CharT, typename Traits>
1050 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1051 typename bpstd::basic_string_view<CharT,Traits>::size_type
1053  size_type pos)
1054  const
1055 {
1056  const auto max_index = size();
1057  for (auto i = pos; i < max_index; ++i) {
1058  if (!is_one_of(m_str[i],v)) {
1059  return i;
1060  }
1061  }
1062 
1063  return npos;
1064 }
1065 
1066 template <typename CharT, typename Traits>
1067 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1068 typename bpstd::basic_string_view<CharT,Traits>::size_type
1070  size_type pos)
1071  const
1072 {
1073  return find_first_not_of(basic_string_view<CharT,Traits>(&c, 1), pos);
1074 }
1075 
1076 template <typename CharT, typename Traits>
1077 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1078 typename bpstd::basic_string_view<CharT,Traits>::size_type
1080  size_type pos,
1081  size_type count)
1082  const
1083 {
1084  return find_first_not_of(basic_string_view<CharT,Traits>(s, count), pos);
1085 }
1086 
1087 template <typename CharT, typename Traits>
1088 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1089 typename bpstd::basic_string_view<CharT,Traits>::size_type
1091  size_type pos)
1092  const
1093 {
1094  return find_first_not_of(basic_string_view<CharT,Traits>(s), pos);
1095 }
1096 
1097 //------------------------------------------------------------------------------
1098 
1099 template <typename CharT, typename Traits>
1100 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1101 typename bpstd::basic_string_view<CharT,Traits>::size_type
1103  size_type pos)
1104  const
1105 {
1106  if (empty()) {
1107  return npos;
1108  }
1109  const auto max_index = std::min(size() - 1, pos);
1110  for (auto i = 0u; i <= max_index; ++i) {
1111  const auto j = max_index - i;
1112 
1113  if (!is_one_of(m_str[j],v)) {
1114  return j;
1115  }
1116  }
1117 
1118  return npos;
1119 }
1120 
1121 template <typename CharT, typename Traits>
1122 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1123 typename bpstd::basic_string_view<CharT,Traits>::size_type
1125  size_type pos)
1126  const
1127 {
1128  return find_last_not_of(basic_string_view<CharT,Traits>(&c, 1), pos);
1129 }
1130 
1131 template <typename CharT, typename Traits>
1132 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1133 typename bpstd::basic_string_view<CharT,Traits>::size_type
1135  size_type pos,
1136  size_type count)
1137  const
1138 {
1139  return find_last_not_of(basic_string_view<CharT,Traits>(s, count), pos);
1140 }
1141 
1142 template <typename CharT, typename Traits>
1143 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1144 typename bpstd::basic_string_view<CharT,Traits>::size_type
1146  size_type pos)
1147  const
1148 {
1149  return find_last_not_of(basic_string_view<CharT,Traits>(s), pos);
1150 }
1151 
1152 //------------------------------------------------------------------------------
1153 // Iterator
1154 //------------------------------------------------------------------------------
1155 
1156 template <typename CharT, typename Traits>
1157 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1158 typename bpstd::basic_string_view<CharT,Traits>::const_iterator
1160  const noexcept
1161 {
1162  return m_str;
1163 }
1164 
1165 template <typename CharT, typename Traits>
1166 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1167 typename bpstd::basic_string_view<CharT,Traits>::const_iterator
1169  const noexcept
1170 {
1171  return begin();
1172 }
1173 
1174 template <typename CharT, typename Traits>
1175 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1176 typename bpstd::basic_string_view<CharT,Traits>::const_iterator
1178  const noexcept
1179 {
1180  return m_str + m_size;
1181 }
1182 
1183 template <typename CharT, typename Traits>
1184 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1185 typename bpstd::basic_string_view<CharT,Traits>::const_iterator
1187  const noexcept
1188 {
1189  return cend();
1190 }
1191 
1192 template <typename CharT, typename Traits>
1193 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1194 typename bpstd::basic_string_view<CharT,Traits>::const_reverse_iterator
1196  const noexcept
1197 {
1198  return const_reverse_iterator{end()};
1199 }
1200 
1201 template <typename CharT, typename Traits>
1202 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1203 typename bpstd::basic_string_view<CharT,Traits>::const_reverse_iterator
1205  const noexcept
1206 {
1207  return rbegin();
1208 }
1209 
1210 template <typename CharT, typename Traits>
1211 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1212 typename bpstd::basic_string_view<CharT,Traits>::const_reverse_iterator
1214  const noexcept
1215 {
1216  return const_reverse_iterator{begin()};
1217 }
1218 
1219 template <typename CharT, typename Traits>
1220 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1221 typename bpstd::basic_string_view<CharT,Traits>::const_reverse_iterator
1223  const noexcept
1224 {
1225  return crend();
1226 }
1227 
1228 template <typename CharT, typename Traits>
1229 inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1231  basic_string_view str)
1232 {
1233  for (auto s : str) {
1234  if (Traits::eq(c,s)) {
1235  return true;
1236  }
1237  }
1238  return false;
1239 }
1240 
1241 //------------------------------------------------------------------------------
1242 // Public Functions
1243 //------------------------------------------------------------------------------
1244 
1245 template <typename CharT, typename Traits>
1246 inline BPSTD_INLINE_VISIBILITY
1247 std::basic_ostream<CharT,Traits>&
1248  bpstd::operator<<(std::basic_ostream<CharT,Traits>& o,
1249  const basic_string_view<CharT,Traits>& str)
1250 {
1251  o.write(str.data(),static_cast<std::streamsize>(str.size()));
1252  return o;
1253 }
1254 
1255 template <typename CharT, typename Traits>
1256 inline BPSTD_INLINE_VISIBILITY
1257 void bpstd::swap(basic_string_view<CharT,Traits>& lhs,
1258  basic_string_view<CharT,Traits>& rhs)
1259  noexcept
1260 {
1261  lhs.swap(rhs);
1262 }
1263 
1264 //------------------------------------------------------------------------------
1265 // Comparison Functions
1266 //------------------------------------------------------------------------------
1267 
1268 namespace bpstd {
1269 
1270  template <typename CharT, typename Traits>
1271  inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1272  bool operator==(const basic_string_view<CharT,Traits>& lhs,
1273  const basic_string_view<CharT,Traits>& rhs)
1274  noexcept
1275  {
1276  return lhs.compare(rhs) == 0;
1277  }
1278 
1279  template <typename CharT, typename Traits>
1280  inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1281  bool operator==(basic_string_view<CharT,Traits> lhs, const CharT* rhs)
1282  noexcept
1283  {
1284  return lhs == basic_string_view<CharT,Traits>(rhs);
1285  }
1286 
1287  template <typename CharT, typename Traits>
1288  inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1289  bool operator==(const CharT* lhs, const basic_string_view<CharT,Traits>& rhs)
1290  noexcept
1291  {
1292  return basic_string_view<CharT,Traits>(lhs) == rhs;
1293  }
1294 
1295  template <typename CharT, typename Traits, typename Allocator>
1296  inline BPSTD_INLINE_VISIBILITY
1297  bool operator==(const std::basic_string<CharT,Traits,Allocator>& lhs,
1298  const basic_string_view<CharT,Traits>& rhs)
1299  {
1300  return basic_string_view<CharT,Traits>(lhs) == rhs;
1301  }
1302 
1303  template <typename CharT, typename Traits, typename Allocator>
1304  inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1305  bool operator==(const basic_string_view<CharT,Traits>& lhs,
1306  const std::basic_string<CharT,Traits,Allocator>& rhs)
1307  {
1308  return lhs == basic_string_view<CharT,Traits>(rhs);
1309  }
1310 
1311  //----------------------------------------------------------------------------
1312 
1313  template <typename CharT, typename Traits>
1314  inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1315  bool operator!=(const basic_string_view<CharT,Traits>& lhs,
1316  const basic_string_view<CharT,Traits>& rhs)
1317  noexcept
1318  {
1319  return lhs.compare(rhs) != 0;
1320  }
1321 
1322  template <typename CharT, typename Traits>
1323  inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1324  bool operator!=(const basic_string_view<CharT,Traits>& lhs, const CharT* rhs)
1325  noexcept
1326  {
1327  return lhs != basic_string_view<CharT,Traits>(rhs);
1328  }
1329 
1330  template <typename CharT, typename Traits>
1331  inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1332  bool operator!=(const CharT* lhs, const basic_string_view<CharT,Traits>& rhs)
1333  noexcept
1334  {
1335  return basic_string_view<CharT,Traits>(lhs) != rhs;
1336  }
1337 
1338  template <typename CharT, typename Traits, typename Allocator>
1339  inline BPSTD_INLINE_VISIBILITY
1340  bool operator!=(const std::basic_string<CharT,Traits,Allocator>& lhs,
1341  const basic_string_view<CharT,Traits>& rhs)
1342  {
1343  return basic_string_view<CharT,Traits>(lhs) != rhs;
1344  }
1345 
1346  template <typename CharT, typename Traits, typename Allocator>
1347  inline BPSTD_INLINE_VISIBILITY
1348  bool operator!=(const basic_string_view<CharT,Traits>& lhs,
1349  const std::basic_string<CharT,Traits,Allocator>& rhs)
1350  {
1351  return lhs != basic_string_view<CharT,Traits>(rhs);
1352  }
1353  //----------------------------------------------------------------------------
1354 
1355  template <typename CharT, typename Traits>
1356  inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1357  bool operator<(const basic_string_view<CharT,Traits>& lhs,
1358  const basic_string_view<CharT,Traits>& rhs)
1359  noexcept
1360  {
1361  return lhs.compare(rhs) < 0;
1362  }
1363 
1364  template <typename CharT, typename Traits>
1365  inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1366  bool operator<(const basic_string_view<CharT,Traits>& lhs, const CharT* rhs)
1367  noexcept
1368  {
1369  return lhs < basic_string_view<CharT,Traits>(rhs);
1370  }
1371 
1372  template <typename CharT, typename Traits>
1373  inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1374  bool operator<(const CharT* lhs, const basic_string_view<CharT,Traits>& rhs)
1375  noexcept
1376  {
1377  return basic_string_view<CharT,Traits>(lhs) < rhs;
1378  }
1379 
1380  template <typename CharT, typename Traits, typename Allocator>
1381  inline BPSTD_INLINE_VISIBILITY
1382  bool operator<(const std::basic_string<CharT,Traits,Allocator>& lhs,
1383  const basic_string_view<CharT,Traits>& rhs)
1384  {
1385  return basic_string_view<CharT,Traits>(lhs) < rhs;
1386  }
1387 
1388  template <typename CharT, typename Traits, typename Allocator>
1389  inline BPSTD_INLINE_VISIBILITY
1390  bool operator<(const basic_string_view<CharT,Traits>& lhs,
1391  const std::basic_string<CharT,Traits,Allocator>& rhs)
1392  {
1393  return lhs < basic_string_view<CharT,Traits>(rhs);
1394  }
1395 
1396  //----------------------------------------------------------------------------
1397 
1398  template <typename CharT, typename Traits>
1399  inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1400  bool operator>(const basic_string_view<CharT,Traits>& lhs,
1401  const basic_string_view<CharT,Traits>& rhs)
1402  noexcept
1403  {
1404  return lhs.compare(rhs) > 0;
1405  }
1406 
1407  template <typename CharT, typename Traits>
1408  inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1409  bool operator>(const basic_string_view<CharT,Traits>& lhs, const CharT* rhs)
1410  noexcept
1411  {
1412  return lhs > basic_string_view<CharT,Traits>(rhs);
1413  }
1414 
1415  template <typename CharT, typename Traits>
1416  inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1417  bool operator>(const CharT* lhs, const basic_string_view<CharT,Traits>& rhs)
1418  noexcept
1419  {
1420  return basic_string_view<CharT,Traits>(lhs) > rhs;
1421  }
1422 
1423  template <typename CharT, typename Traits, typename Allocator>
1424  inline BPSTD_INLINE_VISIBILITY
1425  bool operator>(const std::basic_string<CharT,Traits,Allocator>& lhs,
1426  const basic_string_view<CharT,Traits>& rhs)
1427  {
1428  return basic_string_view<CharT,Traits>(lhs) > rhs;
1429  }
1430 
1431  template <typename CharT, typename Traits, typename Allocator>
1432  inline BPSTD_INLINE_VISIBILITY
1433  bool operator>(const basic_string_view<CharT,Traits>& lhs,
1434  const std::basic_string<CharT,Traits,Allocator>& rhs)
1435  {
1436  return lhs > basic_string_view<CharT,Traits>(rhs);
1437  }
1438 
1439  //----------------------------------------------------------------------------
1440 
1441  template <typename CharT, typename Traits>
1442  inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1443  bool operator<=(const basic_string_view<CharT,Traits>& lhs,
1444  const basic_string_view<CharT,Traits>& rhs)
1445  noexcept
1446  {
1447  return lhs.compare(rhs) <= 0;
1448  }
1449 
1450  template <typename CharT, typename Traits>
1451  inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1452  bool operator<=(const basic_string_view<CharT,Traits>& lhs, const CharT* rhs)
1453  noexcept
1454  {
1455  return lhs <= basic_string_view<CharT,Traits>(rhs);
1456  }
1457 
1458  template <typename CharT, typename Traits>
1459  inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1460  bool operator<=(const CharT* lhs, const basic_string_view<CharT,Traits>& rhs)
1461  noexcept
1462  {
1463  return basic_string_view<CharT,Traits>(lhs) <= rhs;
1464  }
1465 
1466  template <typename CharT, typename Traits, typename Allocator>
1467  inline BPSTD_INLINE_VISIBILITY
1468  bool operator<=(const std::basic_string<CharT,Traits,Allocator>& lhs,
1469  const basic_string_view<CharT,Traits>& rhs)
1470  {
1471  return basic_string_view<CharT,Traits>(lhs) <= rhs;
1472  }
1473 
1474  template <typename CharT, typename Traits, typename Allocator>
1475  inline BPSTD_INLINE_VISIBILITY
1476  bool operator<=(const basic_string_view<CharT,Traits>& lhs,
1477  const std::basic_string<CharT,Traits,Allocator>& rhs)
1478  {
1479  return lhs <= basic_string_view<CharT,Traits>(rhs);
1480  }
1481 
1482  //----------------------------------------------------------------------------
1483 
1484  template <typename CharT, typename Traits>
1485  inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1486  bool operator>=(const basic_string_view<CharT,Traits>& lhs,
1487  const basic_string_view<CharT,Traits>& rhs)
1488  noexcept
1489  {
1490  return lhs.compare(rhs) >= 0;
1491  }
1492 
1493  template <typename CharT, typename Traits>
1494  inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1495  bool operator>=(const basic_string_view<CharT,Traits>& lhs, const CharT* rhs)
1496  noexcept
1497  {
1498  return lhs >= basic_string_view<CharT,Traits>(rhs);
1499  }
1500 
1501  template <typename CharT, typename Traits>
1502  inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR
1503  bool operator>=(const CharT* lhs, const basic_string_view<CharT,Traits>& rhs)
1504  noexcept
1505  {
1506  return basic_string_view<CharT,Traits>(lhs) >= rhs;
1507  }
1508 
1509  template <typename CharT, typename Traits, typename Allocator>
1510  inline BPSTD_INLINE_VISIBILITY
1511  bool operator>=(const std::basic_string<CharT,Traits,Allocator>& lhs,
1512  const basic_string_view<CharT,Traits>& rhs)
1513  {
1514  return basic_string_view<CharT,Traits>(lhs) >= rhs;
1515  }
1516 
1517  template <typename CharT, typename Traits, typename Allocator>
1518  inline BPSTD_INLINE_VISIBILITY
1519  bool operator>=(const basic_string_view<CharT,Traits>& lhs,
1520  const std::basic_string<CharT,Traits,Allocator>& rhs)
1521  {
1522  return lhs >= basic_string_view<CharT,Traits>(rhs);
1523  }
1524 
1525 } // namespace bpstd
1526 
1527 BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE
1528 
1529 #endif /* BPSTD_STRING_VIEW_HPP */
bpstd::basic_string_view::basic_string_view
constexpr basic_string_view() noexcept
Default constructs a basic_string_view without any content.
Definition: string_view.hpp:525
bpstd::basic_string_view::cend
BPSTD_CPP14_CONSTEXPR const_iterator cend() const noexcept
Retrieves the end iterator for this basic_string_view.
Definition: string_view.hpp:1186
bpstd::basic_string_view::front
constexpr const_reference front() const noexcept
Access the first character of the string.
Definition: string_view.hpp:642
bpstd::basic_string_view::copy
BPSTD_CPP14_CONSTEXPR size_type copy(char_type *dest, size_type count=npos, size_type pos=0) const
Copies the substring [pos, pos + rcount) to the character string pointed to by dest,...
Definition: string_view.hpp:708
bpstd::basic_string_view::at
constexpr const_reference at(size_type pos) const
Accesses the element at index pos.
Definition: string_view.hpp:631
bpstd::size
constexpr auto size(const C &c) -> decltype(c.size())
Gets the size of a container.
bpstd::basic_string_view
A semantic non-owning wrapper around contiguous character sequences.
Definition: string_view.hpp:61
bpstd::basic_string_view::size
constexpr size_type size() const noexcept
Returns the length of the string, in terms of bytes.
Definition: string_view.hpp:574
bpstd::basic_string_view::rend
BPSTD_CPP14_CONSTEXPR const_reverse_iterator rend() const noexcept
Retrieves the reverse begin iterator for this basic_string_view.
Definition: string_view.hpp:1213
bpstd::basic_string_view::begin
BPSTD_CPP14_CONSTEXPR const_iterator begin() const noexcept
Retrieves the begin iterator for this basic_string_view.
Definition: string_view.hpp:1159
bpstd::basic_string_view::data
constexpr const char_type * data() const noexcept
Gets the data of the current basic_string_view.
Definition: string_view.hpp:613
bpstd::basic_string_view::length
constexpr size_type length() const noexcept
Returns the length of the string, in terms of bytes.
Definition: string_view.hpp:583
bpstd::operator<<
std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &o, const basic_string_view< CharT, Traits > &str)
Overload for ostream output of basic_string_view.
bpstd::basic_string_view::substr
BPSTD_CPP14_CONSTEXPR basic_string_view substr(size_t pos=0, size_t len=npos) const
Returns a substring of this viewed string.
Definition: string_view.hpp:730
bpstd::basic_string_view::crbegin
BPSTD_CPP14_CONSTEXPR const_reverse_iterator crbegin() const noexcept
Retrieves the reverse end iterator for this basic_string_view.
Definition: string_view.hpp:1204
bpstd::basic_string_view::empty
constexpr bool empty() const noexcept
Returns whether the basic_string_view is empty (i.e. whether its length is 0).
Definition: string_view.hpp:600
bpstd::basic_string_view::rbegin
BPSTD_CPP14_CONSTEXPR const_reverse_iterator rbegin() const noexcept
Retrieves the reverse begin iterator for this basic_string_view.
Definition: string_view.hpp:1195
bpstd::basic_string_view::compare
BPSTD_CPP14_CONSTEXPR int compare(basic_string_view v) const noexcept
Compares two character sequences.
Definition: string_view.hpp:748
bpstd::basic_string_view::operator[]
constexpr const_reference operator[](size_type pos) const noexcept
Accesses the element at index pos.
Definition: string_view.hpp:622
bpstd::empty
constexpr auto empty(const C &c) -> decltype(c.empty())
Queries whether c is empty.
bpstd::swap
void swap(any &lhs, any &rhs) noexcept
Swaps the contents of lhs and rhs.
Definition: any.hpp:833
bpstd::basic_string_view::remove_prefix
BPSTD_CPP14_CONSTEXPR void remove_prefix(size_type n) noexcept
Moves the start of the view forward by n characters.
Definition: string_view.hpp:663
bpstd::basic_string_view::max_size
constexpr size_type max_size() const noexcept
The largest possible number of char-like objects that can be referred to by a basic_string_view.
Definition: string_view.hpp:592
bpstd::basic_string_view::cbegin
BPSTD_CPP14_CONSTEXPR const_iterator cbegin() const noexcept
Retrieves the begin iterator for this basic_string_view.
Definition: string_view.hpp:1168
bpstd::basic_string_view::end
BPSTD_CPP14_CONSTEXPR const_iterator end() const noexcept
Retrieves the end iterator for this basic_string_view.
Definition: string_view.hpp:1177
bpstd::basic_string_view::swap
BPSTD_CPP14_CONSTEXPR void swap(basic_string_view &v) noexcept
Exchanges the view with that of v.
Definition: string_view.hpp:679
bpstd::basic_string_view::operator=
basic_string_view & operator=(const basic_string_view &view)=default
Assigns a basic_string_view from an ansi-string.
bpstd::swap
void swap(variant< Types... > &lhs, variant< Types... > &rhs) noexcept(noexcept(lhs.swap(rhs)))
Swaps the contents of lhs with rhs.
bpstd::basic_string_view::remove_suffix
BPSTD_CPP14_CONSTEXPR void remove_suffix(size_type n) noexcept
Moves the end of the view back by n characters.
Definition: string_view.hpp:671
bpstd::basic_string_view::crend
BPSTD_CPP14_CONSTEXPR const_reverse_iterator crend() const noexcept
Retrieves the reverse end iterator for this basic_string_view.
Definition: string_view.hpp:1222
bpstd::basic_string_view::back
constexpr const_reference back() const noexcept
References the last character of the string.
Definition: string_view.hpp:651