Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Class template basic_string_view
PrevUpHomeNext

Class template basic_string_view

boost::basic_string_view

Synopsis

// In header: <boost/utility/string_view.hpp>

template<typename charT, typename traits> 
class basic_string_view {
public:
  // types
  typedef traits                                  traits_type;           
  typedef charT                                   value_type;            
  typedef charT *                                 pointer;               
  typedef const charT *                           const_pointer;         
  typedef charT &                                 reference;             
  typedef const charT &                           const_reference;       
  typedef const_pointer                           const_iterator;        
  typedef const_iterator                          iterator;              
  typedef std::reverse_iterator< const_iterator > const_reverse_iterator;
  typedef const_reverse_iterator                  reverse_iterator;      
  typedef std::size_t                             size_type;             
  typedef std::ptrdiff_t                          difference_type;       

  // public member functions
  basic_string_view() noexcept;
  basic_string_view(const basic_string_view &);
  basic_string_view & operator=(const basic_string_view &);
  template<typename Allocator> 
    basic_string_view(const std::basic_string< charT, traits, Allocator > &) noexcept;
  basic_string_view(const charT *);
  basic_string_view(const charT *, size_type);
  const_iterator begin() const noexcept;
  const_iterator cbegin() const noexcept;
  const_iterator end() const noexcept;
  const_iterator cend() const noexcept;
  const_reverse_iterator rbegin() const noexcept;
  const_reverse_iterator crbegin() const noexcept;
  const_reverse_iterator rend() const noexcept;
  const_reverse_iterator crend() const noexcept;
  size_type size() const noexcept;
  size_type length() const noexcept;
  size_type max_size() const noexcept;
  bool empty() const noexcept;
  const_reference operator[](size_type) const noexcept;
  const_reference at(size_type) const;
  const_reference front() const;
  const_reference back() const;
  const_pointer data() const noexcept;
  void clear() noexcept;
  void remove_prefix(size_type);
  void remove_suffix(size_type);
  void swap(basic_string_view &) noexcept;
  template<typename Allocator> 
    explicit operator std::basic_string< charT, traits, Allocator >() const;
  template<typename Allocator = std::allocator<charT> > 
    std::basic_string< charT, traits, Allocator > 
    to_string(const Allocator & = Allocator()) const;
  size_type copy(charT *, size_type, size_type = 0) const;
  basic_string_view substr() const;
  basic_string_view substr(size_type, size_type = npos) const;
  int compare(basic_string_view) const noexcept;
  int compare(size_type, size_type, basic_string_view) const;
  int compare(size_type, size_type, basic_string_view, size_type, size_type) const;
  int compare(const charT *) const;
  int compare(size_type, size_type, const charT *) const;
  int compare(size_type, size_type, const charT *, size_type) const;
  bool starts_with(charT) const noexcept;
  bool starts_with(basic_string_view) const noexcept;
  bool ends_with(charT) const noexcept;
  bool ends_with(basic_string_view) const noexcept;
  bool contains(basic_string_view) const noexcept;
  bool contains(charT) const noexcept;
  bool contains(const charT *) const noexcept;
  size_type find(basic_string_view, size_type = 0) const noexcept;
  size_type find(charT, size_type = 0) const noexcept;
  size_type find(const charT *, size_type, size_type) const noexcept;
  size_type find(const charT *, size_type = 0) const noexcept;
  size_type rfind(basic_string_view, size_type = npos) const noexcept;
  size_type rfind(charT, size_type = npos) const noexcept;
  size_type rfind(const charT *, size_type, size_type) const noexcept;
  size_type rfind(const charT *, size_type = npos) const noexcept;
  size_type find_first_of(basic_string_view, size_type = 0) const noexcept;
  size_type find_first_of(charT, size_type = 0) const noexcept;
  size_type find_first_of(const charT *, size_type, size_type) const noexcept;
  size_type find_first_of(const charT *, size_type = 0) const noexcept;
  size_type find_last_of(basic_string_view, size_type = npos) const noexcept;
  size_type find_last_of(charT, size_type = npos) const noexcept;
  size_type find_last_of(const charT *, size_type, size_type) const noexcept;
  size_type find_last_of(const charT *, size_type = npos) const noexcept;
  size_type find_first_not_of(basic_string_view, size_type = 0) const noexcept;
  size_type find_first_not_of(charT, size_type = 0) const noexcept;
  size_type find_first_not_of(const charT *, size_type, size_type) const noexcept;
  size_type find_first_not_of(const charT *, size_type = 0) const noexcept;
  size_type find_last_not_of(basic_string_view, size_type = npos) const noexcept;
  size_type find_last_not_of(charT, size_type = npos) const noexcept;
  size_type find_last_not_of(const charT *, size_type, size_type) const noexcept;
  size_type find_last_not_of(const charT *, size_type = npos) const noexcept;

  // private member functions
  template<typename r_iter> 
    size_type reverse_distance(r_iter, r_iter) const noexcept;
  template<typename Iterator> 
    Iterator find_not_of(Iterator, Iterator, basic_string_view) const noexcept;

  // public data members
  static size_type npos;
};

Description

basic_string_view public member functions

  1. basic_string_view() noexcept;
  2. basic_string_view(const basic_string_view & rhs);
  3. basic_string_view & operator=(const basic_string_view & rhs);
  4. template<typename Allocator> 
      basic_string_view(const std::basic_string< charT, traits, Allocator > & str) noexcept;
  5. basic_string_view(const charT * str);
  6. basic_string_view(const charT * str, size_type len);
  7. const_iterator begin() const noexcept;
  8. const_iterator cbegin() const noexcept;
  9. const_iterator end() const noexcept;
  10. const_iterator cend() const noexcept;
  11. const_reverse_iterator rbegin() const noexcept;
  12. const_reverse_iterator crbegin() const noexcept;
  13. const_reverse_iterator rend() const noexcept;
  14. const_reverse_iterator crend() const noexcept;
  15. size_type size() const noexcept;
  16. size_type length() const noexcept;
  17. size_type max_size() const noexcept;
  18. bool empty() const noexcept;
  19. const_reference operator[](size_type pos) const noexcept;
  20. const_reference at(size_type pos) const;
  21. const_reference front() const;
  22. const_reference back() const;
  23. const_pointer data() const noexcept;
  24. void clear() noexcept;
  25. void remove_prefix(size_type n);
  26. void remove_suffix(size_type n);
  27. void swap(basic_string_view & s) noexcept;
  28. template<typename Allocator> 
      explicit operator std::basic_string< charT, traits, Allocator >() const;
  29. template<typename Allocator = std::allocator<charT> > 
      std::basic_string< charT, traits, Allocator > 
      to_string(const Allocator & a = Allocator()) const;
  30. size_type copy(charT * s, size_type n, size_type pos = 0) const;
  31. basic_string_view substr() const;
  32. basic_string_view substr(size_type pos, size_type n = npos) const;
  33. int compare(basic_string_view x) const noexcept;
  34. int compare(size_type pos1, size_type n1, basic_string_view x) const;
  35. int compare(size_type pos1, size_type n1, basic_string_view x, size_type pos2, 
                size_type n2) const;
  36. int compare(const charT * x) const;
  37. int compare(size_type pos1, size_type n1, const charT * x) const;
  38. int compare(size_type pos1, size_type n1, const charT * x, size_type n2) const;
  39. bool starts_with(charT c) const noexcept;
  40. bool starts_with(basic_string_view x) const noexcept;
  41. bool ends_with(charT c) const noexcept;
  42. bool ends_with(basic_string_view x) const noexcept;
  43. bool contains(basic_string_view s) const noexcept;
  44. bool contains(charT c) const noexcept;
  45. bool contains(const charT * s) const noexcept;
  46. size_type find(basic_string_view s, size_type pos = 0) const noexcept;
  47. size_type find(charT c, size_type pos = 0) const noexcept;
  48. size_type find(const charT * s, size_type pos, size_type n) const noexcept;
  49. size_type find(const charT * s, size_type pos = 0) const noexcept;
  50. size_type rfind(basic_string_view s, size_type pos = npos) const noexcept;
  51. size_type rfind(charT c, size_type pos = npos) const noexcept;
  52. size_type rfind(const charT * s, size_type pos, size_type n) const noexcept;
  53. size_type rfind(const charT * s, size_type pos = npos) const noexcept;
  54. size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept;
  55. size_type find_first_of(charT c, size_type pos = 0) const noexcept;
  56. size_type find_first_of(const charT * s, size_type pos, size_type n) const noexcept;
  57. size_type find_first_of(const charT * s, size_type pos = 0) const noexcept;
  58. size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept;
  59. size_type find_last_of(charT c, size_type pos = npos) const noexcept;
  60. size_type find_last_of(const charT * s, size_type pos, size_type n) const noexcept;
  61. size_type find_last_of(const charT * s, size_type pos = npos) const noexcept;
  62. size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept;
  63. size_type find_first_not_of(charT c, size_type pos = 0) const noexcept;
  64. size_type find_first_not_of(const charT * s, size_type pos, size_type n) const noexcept;
  65. size_type find_first_not_of(const charT * s, size_type pos = 0) const noexcept;
  66. size_type find_last_not_of(basic_string_view s, size_type pos = npos) const noexcept;
  67. size_type find_last_not_of(charT c, size_type pos = npos) const noexcept;
  68. size_type find_last_not_of(const charT * s, size_type pos, size_type n) const noexcept;
  69. size_type find_last_not_of(const charT * s, size_type pos = npos) const noexcept;

basic_string_view private member functions

  1. template<typename r_iter> 
      size_type reverse_distance(r_iter first, r_iter last) const noexcept;
  2. template<typename Iterator> 
      Iterator find_not_of(Iterator first, Iterator last, basic_string_view s) const noexcept;

PrevUpHomeNext