| Home | Libraries | People | FAQ | More

## Class template basic_string_ref

boost::basic_string_ref

## Synopsis

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

    template<typename charT, typename traits>
    class basic_string_ref {
    public:
      // types
      typedef charT                                   value_type;
      typedef const charT *                           pointer;
      typedef const charT &                           reference;
      typedef const charT &                           const_reference;
      typedef 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_ref() noexcept;
      basic_string_ref(const basic_string_ref &);
      basic_string_ref & operator=(const basic_string_ref &);
      basic_string_ref(const charT *) noexcept;
      template<typename Allocator>
        basic_string_ref(const std::basic_string< charT, traits, Allocator > &);
      basic_string_ref(const charT *, size_type) noexcept;
      template<typename Allocator>
        explicit operator std::basic_string< charT, traits, Allocator >() const;
      std::basic_string< charT, traits > to_string() const;
      const_iterator begin() const;
      const_iterator cbegin() const;
      const_iterator end() const;
      const_iterator cend() const;
      const_reverse_iterator rbegin() const;
      const_reverse_iterator crbegin() const;
      const_reverse_iterator rend() const;
      const_reverse_iterator crend() const;
      size_type size() const;
      size_type length() const;
      size_type max_size() const;
      bool empty() const;
      const charT & operator[](size_type) const;
      const charT & at(size_type) const;
      const charT & front() const;
      const charT & back() const;
      const charT * data() const;
      void clear();
      void remove_prefix(size_type);
      void remove_suffix(size_type);
      basic_string_ref substr() const;
      basic_string_ref substr(size_type, size_type = npos) const;
      int compare(basic_string_ref) const;
      bool starts_with(charT) const;
      bool starts_with(basic_string_ref) const;
      bool ends_with(charT) const;
      bool ends_with(basic_string_ref) const;
      size_type find(basic_string_ref) const;
      size_type find(charT) const;
      size_type rfind(basic_string_ref) const;
      size_type rfind(charT) const;
      size_type find_first_of(charT) const;
      size_type find_last_of(charT) const;
      size_type find_first_of(basic_string_ref) const;
      size_type find_last_of(basic_string_ref) const;
      size_type find_first_not_of(basic_string_ref) const;
      size_type find_first_not_of(charT) const;
      size_type find_last_not_of(basic_string_ref) const;
      size_type find_last_not_of(charT) const;

      // private member functions
      template<typename Iterator>
        Iterator find_not_of(Iterator, Iterator, basic_string_ref) const;

      // public data members
      static size_type npos;
    };

## Description

### `basic_string_ref` public member functions

1.     basic_string_ref() noexcept;

2.     basic_string_ref(const basic_string_ref & rhs);

3.     basic_string_ref & operator=(const basic_string_ref & rhs);

4.     basic_string_ref(const charT * str) noexcept;

5.     template<typename Allocator>
         basic_string_ref(const std::basic_string< charT, traits, Allocator > & str);

6.     basic_string_ref(const charT * str, size_type len) noexcept;

7.     template<typename Allocator>
         explicit operator std::basic_string< charT, traits, Allocator >() const;

8.     std::basic_string< charT, traits > to_string() const;

9.     const_iterator begin() const;

10.     const_iterator cbegin() const;

11.     const_iterator end() const;

12.     const_iterator cend() const;

13.     const_reverse_iterator rbegin() const;

14.     const_reverse_iterator crbegin() const;

15.     const_reverse_iterator rend() const;

16.     const_reverse_iterator crend() const;

17.     size_type size() const;

18.     size_type length() const;

19.     size_type max_size() const;

20.     bool empty() const;

21.     const charT & operator[](size_type pos) const;

22.     const charT & at(size_type pos) const;

23.     const charT & front() const;

24.     const charT & back() const;

25.     const charT * data() const;

26.     void clear();

27.     void remove_prefix(size_type n);

28.     void remove_suffix(size_type n);

29.     basic_string_ref substr() const;

30.     basic_string_ref substr(size_type pos, size_type n = npos) const;

31.     int compare(basic_string_ref x) const;

32.     bool starts_with(charT c) const;

33.     bool starts_with(basic_string_ref x) const;

34.     bool ends_with(charT c) const;

35.     bool ends_with(basic_string_ref x) const;

36.     size_type find(basic_string_ref s) const;

37.     size_type find(charT c) const;

38.     size_type rfind(basic_string_ref s) const;

39.     size_type rfind(charT c) const;

40.     size_type find_first_of(charT c) const;

41.     size_type find_last_of(charT c) const;

42.     size_type find_first_of(basic_string_ref s) const;

43.     size_type find_last_of(basic_string_ref s) const;

44.     size_type find_first_not_of(basic_string_ref s) const;

45.     size_type find_first_not_of(charT c) const;

46.     size_type find_last_not_of(basic_string_ref s) const;

47.     size_type find_last_not_of(charT c) const;

### `basic_string_ref` private member functions

1.     template<typename Iterator>
         Iterator find_not_of(Iterator first, Iterator last, basic_string_ref s) const;