Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template basic_string

boost::container::basic_string

Synopsis

// In header: <boost/container/string.hpp>

template<typename CharT, typename Traits = std::char_traits<CharT>, 
         typename Allocator = void> 
class basic_string : private boost::container::dtl::basic_string_base< real_allocator< CharT, Allocator >::type >
{
public:
  // types
  typedef Traits                                                                  traits_type;    
  typedef CharT                                                                   value_type;     
  typedef real_allocator< CharT, Allocator >::type                                allocator_type; 
  typedef ::boost::container::allocator_traits< allocator_type >::pointer         pointer;        
  typedef ::boost::container::allocator_traits< allocator_type >::const_pointer   const_pointer;  
  typedef ::boost::container::allocator_traits< allocator_type >::reference       reference;      
  typedef ::boost::container::allocator_traits< allocator_type >::const_reference const_reference;
  typedef ::boost::container::allocator_traits< allocator_type >::size_type       size_type;      
  typedef ::boost::container::allocator_traits< allocator_type >::difference_type difference_type;

  // member classes/structs/unions
  template<typename CharT, typename Traits, typename Allocator> 
  struct Eq_traits {
    // types
    typedef Tr::char_type first_argument_type; 
    typedef Tr::char_type second_argument_type;
    typedef bool          result_type;         

    // public member functions
    bool operator()(const first_argument_type &, const second_argument_type &) const;
  };
  template<typename CharT, typename Traits, typename Allocator> 
  struct Not_within_traits {
    // types
    typedef Tr::char_type argument_type;
    typedef bool          result_type;  

    // construct/copy/destruct
    Not_within_traits(Pointer, Pointer);

    // public member functions
    bool operator()(const typename Tr::char_type &) const;

    // public data members
    const typedef Tr::char_type * Pointer;
    const Pointer m_first;
    const Pointer m_last;
  };
  template<typename CharT, typename Traits, typename Allocator> 
  struct reserve_t {
  };

  // construct/copy/destruct
  basic_string(reserve_t, size_type, 
               const allocator_type & = allocator_type());
  basic_string() noexcept(condition);
  explicit basic_string(const allocator_type &);
  basic_string(const basic_string &);
  template<template< class, class > class BasicStringView> 
    explicit basic_string(BasicStringView< CharT, Traits >, 
                          const allocator_type & = allocator_type());
  basic_string(BOOST_RV_REF(basic_string));
  basic_string(const basic_string &, const allocator_type &);
  basic_string(BOOST_RV_REF(basic_string), const allocator_type &);
  basic_string(const basic_string &, size_type, size_type = npos);
  basic_string(const basic_string &, size_type, size_type, 
               const allocator_type &);
  basic_string(const CharT *, size_type);
  basic_string(const CharT *, size_type, const allocator_type &);
  basic_string(const CharT *);
  basic_string(const CharT *, const allocator_type &);
  basic_string(size_type, CharT);
  basic_string(size_type, CharT, const allocator_type &);
  basic_string(size_type, default_init_t);
  basic_string(size_type, default_init_t, const allocator_type &);
  template<typename InputIterator> basic_string(InputIterator, InputIterator);
  template<typename InputIterator> 
    basic_string(InputIterator, InputIterator, const allocator_type &);
  basic_string(std::initializer_list< value_type >, 
               const allocator_type & = allocator_type());
  basic_string & operator=(BOOST_COPY_ASSIGN_REF(basic_string));
  basic_string & operator=(BOOST_RV_REF(basic_string)) noexcept(condition);
  basic_string & operator=(const CharT *);
  basic_string & operator=(CharT);
  template<template< class, class > class BasicStringView> 
    basic_string & operator=(BasicStringView< CharT, Traits >);
  basic_string & operator=(std::initializer_list< CharT >);
  ~basic_string();

  // public member functions
  typedef BOOST_CONTAINER_IMPDEF(allocator_type);
  typedef BOOST_CONTAINER_IMPDEF(pointer);
  typedef BOOST_CONTAINER_IMPDEF(const_pointer) const;
  typedef BOOST_CONTAINER_IMPDEF(boost::container::reverse_iterator< iterator >);
  typedef BOOST_CONTAINER_IMPDEF(boost::container::reverse_iterator< const_iterator >) const;
  allocator_type get_allocator() const;
  stored_allocator_type & get_stored_allocator();
  const stored_allocator_type & get_stored_allocator() const;
  iterator begin();
  const_iterator begin() const;
  iterator end();
  const_iterator end() const;
  reverse_iterator rbegin();
  const_reverse_iterator rbegin() const;
  reverse_iterator rend();
  const_reverse_iterator rend() const;
  const_iterator cbegin() const;
  const_iterator cend() const;
  const_reverse_iterator crbegin() const;
  const_reverse_iterator crend() const;
  bool empty() const;
  size_type size() const;
  size_type length() const;
  size_type max_size() const;
  void resize(size_type, CharT);
  void resize(size_type);
  void resize(size_type, default_init_t);
  size_type capacity() const;
  void reserve(size_type);
  void shrink_to_fit();
  reference front();
  const_reference front() const;
  reference back();
  const_reference back() const;
  reference operator[](size_type);
  const_reference operator[](size_type) const;
  reference at(size_type);
  const_reference at(size_type) const;
  basic_string & operator+=(const basic_string &);
  template<template< class, class > class BasicStringView> 
    basic_string & operator+=(BasicStringView< CharT, Traits >);
  basic_string & operator+=(const CharT *);
  basic_string & operator+=(CharT);
  basic_string & operator+=(std::initializer_list< CharT >);
  basic_string & append(const basic_string &);
  template<template< class, class > class BasicStringView> 
    basic_string & append(BasicStringView< CharT, Traits >);
  basic_string & append(const basic_string &, size_type, size_type = npos);
  basic_string & append(const CharT *, size_type);
  basic_string & append(const CharT *);
  basic_string & append(size_type, CharT);
  template<typename InputIter> basic_string & append(InputIter, InputIter);
  basic_string & append(std::initializer_list< CharT >);
  void push_back(CharT);
  basic_string & assign(const basic_string &);
  template<template< class, class > class BasicStringView> 
    basic_string & assign(BasicStringView< CharT, Traits >);
  basic_string & assign(BOOST_RV_REF(basic_string));
  basic_string & assign(const basic_string &, size_type, size_type);
  basic_string & assign(const CharT *, size_type);
  basic_string & assign(const CharT *);
  basic_string & assign(size_type, CharT);
  basic_string & assign(const CharT *, const CharT *);
  template<typename InputIter> 
    basic_string & 
    assign(InputIter, InputIter last #if !, 
           typename dtl::disable_if_convertible< InputIter, size_type >::type * = 0 #endif);
  basic_string & assign(std::initializer_list< CharT >);
  basic_string & insert(size_type, const basic_string &);
  basic_string & 
  insert(size_type, const basic_string &, size_type, size_type = npos);
  basic_string & insert(size_type, const CharT *, size_type);
  basic_string & insert(size_type, const CharT *);
  basic_string & insert(size_type, size_type, CharT);
  template<template< class, class > class BasicStringView> 
    basic_string & insert(size_type, BasicStringView< CharT, Traits >);
  iterator insert(const_iterator, CharT);
  iterator insert(const_iterator, size_type, CharT);
  template<typename InputIter> 
    iterator insert(const_iterator, InputIter, InputIter last #if !, 
                    typename dtl::disable_if_or< void, dtl::is_convertible< InputIter, size_type >, dtl::is_not_input_iterator< InputIter > >::type * = 0 #endif);
  template<typename ForwardIter> 
    iterator insert(const_iterator, ForwardIter, ForwardIter, 
                    typename dtl::disable_if_or< void, dtl::is_convertible< ForwardIter, size_type >, dtl::is_input_iterator< ForwardIter > >::type * = 0);
  iterator insert(const_iterator, std::initializer_list< CharT >);
  void pop_back();
  basic_string & erase(size_type = 0, size_type = npos);
  iterator erase(const_iterator);
  iterator erase(const_iterator, const_iterator);
  void clear();
  basic_string & replace(size_type, size_type, const basic_string &);
  template<template< class, class > class BasicStringView> 
    basic_string & 
    replace(size_type, size_type, BasicStringView< CharT, Traits >);
  basic_string & 
  replace(size_type, size_type, const basic_string &, size_type, 
          size_type = npos);
  template<template< class, class > class BasicStringView> 
    basic_string & 
    replace(size_type, size_type, BasicStringView< CharT, Traits >, size_type, 
            size_type = npos);
  basic_string & replace(size_type, size_type, const CharT *, size_type);
  basic_string & replace(size_type, size_type, const CharT *);
  basic_string & replace(size_type, size_type, size_type, CharT);
  basic_string & replace(const_iterator, const_iterator, const basic_string &);
  basic_string & 
  replace(const_iterator, const_iterator, const CharT *, size_type);
  basic_string & replace(const_iterator, const_iterator, const CharT *);
  basic_string & replace(const_iterator, const_iterator, size_type, CharT);
  template<typename InputIter> 
    basic_string & 
    replace(const_iterator, const_iterator, InputIter, InputIter j2 #if !, 
            typename dtl::disable_if_or< void, dtl::is_convertible< InputIter, size_type >, dtl::is_input_iterator< InputIter > >::type * = 0 #endif);
  template<typename ForwardIter> 
    basic_string & 
    replace(const_iterator, const_iterator, ForwardIter, ForwardIter, 
            typename dtl::disable_if_or< void, dtl::is_convertible< ForwardIter, size_type >, dtl::is_not_input_iterator< ForwardIter > >::type * = 0);
  template<template< class, class > class BasicStringView> 
    basic_string & 
    replace(const_iterator, const_iterator, BasicStringView< CharT, Traits >);
  basic_string & 
  replace(const_iterator, const_iterator, std::initializer_list< CharT >);
  size_type copy(CharT *, size_type, size_type = 0) const;
  void swap(basic_string &) noexcept(condition);
  const CharT * c_str() const;
  const CharT * data() const;
  CharT * data();
  template<template< class, class > class BasicStringView> 
    operator BasicStringView< CharT, Traits >() const;
  template<typename BasicStringView> BasicStringView to_view() const;
  size_type find(const basic_string &, size_type = 0) const;
  template<template< class, class > class BasicStringView> 
    size_type find(BasicStringView< CharT, Traits >, size_type = 0) const;
  size_type find(const CharT *, size_type, size_type) const;
  size_type find(const CharT *, size_type = 0) const;
  size_type find(CharT, size_type = 0) const;
  size_type rfind(const basic_string &, size_type = npos) const;
  template<template< class, class > class BasicStringView> 
    size_type rfind(BasicStringView< CharT, Traits >, size_type = npos) const;
  size_type rfind(const CharT *, size_type, size_type) const;
  size_type rfind(const CharT *, size_type = npos) const;
  size_type rfind(CharT, size_type = npos) const;
  size_type find_first_of(const basic_string &, size_type = 0) const;
  template<template< class, class > class BasicStringView> 
    size_type find_first_of(BasicStringView< CharT, Traits >, size_type = 0) const;
  size_type find_first_of(const CharT *, size_type, size_type) const;
  size_type find_first_of(const CharT *, size_type = 0) const;
  size_type find_first_of(CharT, size_type = 0) const;
  size_type find_last_of(const basic_string &, size_type = npos) const;
  template<template< class, class > class BasicStringView> 
    size_type find_last_of(BasicStringView< CharT, Traits >, size_type = npos) const;
  size_type find_last_of(const CharT *, size_type, size_type) const;
  size_type find_last_of(const CharT *, size_type = npos) const;
  size_type find_last_of(CharT, size_type = npos) const;
  size_type find_first_not_of(const basic_string &, size_type = 0) const;
  template<template< class, class > class BasicStringView> 
    size_type find_first_not_of(BasicStringView< CharT, Traits >, 
                                size_type = 0) const;
  size_type find_first_not_of(const CharT *, size_type, size_type) const;
  size_type find_first_not_of(const CharT *, size_type = 0) const;
  size_type find_first_not_of(CharT, size_type = 0) const;
  size_type find_last_not_of(const basic_string &, size_type = npos) const;
  template<template< class, class > class BasicStringView> 
    size_type find_last_not_of(BasicStringView< CharT, Traits >, 
                               size_type = npos) const;
  size_type find_last_not_of(const CharT *, size_type, size_type) const;
  size_type find_last_not_of(const CharT *, size_type = npos) const;
  size_type find_last_not_of(CharT, size_type = npos) const;
  basic_string substr(size_type = 0, size_type = npos) const;
  int compare(const basic_string &) const;
  template<template< class, class > class BasicStringView> 
    int compare(BasicStringView< CharT, Traits >) const;
  int compare(size_type, size_type, const basic_string &) const;
  template<template< class, class > class BasicStringView> 
    int compare(size_type, size_type, BasicStringView< CharT, Traits >) const;
  int compare(size_type, size_type, const basic_string &, size_type, 
              size_type = npos) const;
  template<template< class, class > class BasicStringView> 
    int compare(size_type, size_type, BasicStringView< CharT, Traits >, 
                size_type, size_type) const;
  int compare(const CharT *) const;
  int compare(size_type, size_type, const CharT *, size_type) const;
  int compare(size_type, size_type, const CharT *) const;

  // private member functions
  void priv_reserve(size_type, const bool = true);
  template<typename AllocVersion> 
    void priv_shrink_to_fit_dynamic_buffer(AllocVersion, 
                                           typename dtl::enable_if< dtl::is_same< AllocVersion, version_1 > >::type * = 0);
  template<typename AllocVersion> 
    void priv_shrink_to_fit_dynamic_buffer(AllocVersion, 
                                           typename dtl::enable_if< dtl::is_same< AllocVersion, version_2 > >::type * = 0);
  void priv_construct_null(pointer);
  void priv_terminate_string();
  template<typename FwdIt, typename Count> 
    void priv_uninitialized_fill_n(FwdIt, Count, const CharT);
  template<typename InpIt, typename FwdIt> 
    size_type priv_uninitialized_copy(InpIt, InpIt, FwdIt);
  template<typename InputIterator, typename OutIterator> 
    void priv_copy(InputIterator, InputIterator, OutIterator);
  void priv_copy(const CharT *, const CharT *, CharT *);
  template<typename Integer> 
    basic_string & 
    priv_replace_dispatch(const_iterator, const_iterator, Integer, Integer, 
                          dtl::true_);
  template<typename InputIter> 
    basic_string & 
    priv_replace_dispatch(const_iterator, const_iterator, InputIter, 
                          InputIter, dtl::false_);

  // private static functions
  template<typename It1, typename It2> 
    static int s_compare(It1, It1, It2, It2);

  // public data members
  static const size_type npos;
};

Description

The basic_string class represents a Sequence of characters. It contains all the usual operations of a Sequence, and, additionally, it contains standard string operations such as search and concatenation.

The basic_string class is parameterized by character type, and by that type's Character Traits.

This class has performance characteristics very much like vector<>, meaning, for example, that it does not perform reference-count or copy-on-write, and that concatenation of two strings is an O(N) operation.

Some of basic_string's member functions use an unusual method of specifying positions and ranges. In addition to the conventional method using iterators, many of basic_string's member functions use a single value pos of type size_type to represent a position (in which case the position is begin() + pos, and many of basic_string's member functions use two values, pos and n, to represent a range. In that case pos is the beginning of the range and n is its size. That is, the range is [begin() + pos, begin() + pos + n).

Note that the C++ standard does not specify the complexity of basic_string operations. In this implementation, basic_string has performance characteristics very similar to those of vector: access to a single character is O(1), while copy and concatenation are O(N).

In this implementation, begin(), end(), rbegin(), rend(), operator[], c_str(), and data() do not invalidate iterators. In this implementation, iterators are only invalidated by member functions that explicitly change the string's contents.

Template Parameters

  1. typename CharT

    The type of character it contains.

  2. typename Traits = std::char_traits<CharT>

    The Character Traits type, which encapsulates basic character operations

  3. typename Allocator = void

    The allocator, used for internal memory management.

basic_string public construct/copy/destruct

  1. basic_string(reserve_t, size_type n, 
                 const allocator_type & a = allocator_type());
  2. basic_string() noexcept(condition);

    Effects: Default constructs a basic_string.

    Throws: If allocator_type's default constructor throws.

  3. explicit basic_string(const allocator_type & a);

    Effects: Constructs a basic_string taking the allocator as parameter.

    Throws: Nothing

  4. basic_string(const basic_string & s);

    Effects: Copy constructs a basic_string.

    Postcondition: x == *this.

    Throws: If allocator_type's default constructor or allocation throws.

  5. template<template< class, class > class BasicStringView> 
      explicit basic_string(BasicStringView< CharT, Traits > sv, 
                            const allocator_type & a = allocator_type());

    Effects: Same as basic_string(sv.data(), sv.size(), a).

    Throws: If allocator_type's default constructor or allocation throws.

  6. basic_string(BOOST_RV_REF(basic_string) s);

    Effects: Move constructor. Moves s's resources to *this.

    Throws: Nothing.

    Complexity: Constant.

  7. basic_string(const basic_string & s, const allocator_type & a);

    Effects: Copy constructs a basic_string using the specified allocator.

    Postcondition: x == *this.

    Throws: If allocation throws.

  8. basic_string(BOOST_RV_REF(basic_string) s, const allocator_type & a);

    Effects: Move constructor using the specified allocator. Moves s's resources to *this.

    Throws: If allocation throws.

    Complexity: Constant if a == s.get_allocator(), linear otherwise.

  9. basic_string(const basic_string & s, size_type pos, size_type n = npos);

    Effects: Constructs a basic_string with a default-constructed allocator, and is initialized by a specific number of characters of the s string.

  10. basic_string(const basic_string & s, size_type pos, size_type n, 
                 const allocator_type & a);

    Effects: Constructs a basic_string taking the allocator as parameter, and is initialized by a specific number of characters of the s string.

  11. basic_string(const CharT * s, size_type n);

    Effects: Constructs a basic_string taking a default-constructed allocator, and is initialized by a specific number of characters of the s c-string.

  12. basic_string(const CharT * s, size_type n, const allocator_type & a);

    Effects: Constructs a basic_string taking the allocator as parameter, and is initialized by a specific number of characters of the s c-string.

  13. basic_string(const CharT * s);

    Effects: Constructs a basic_string with a default-constructed allocator, and is initialized by the null-terminated s c-string.

  14. basic_string(const CharT * s, const allocator_type & a);

    Effects: Constructs a basic_string taking the allocator as parameter, and is initialized by the null-terminated s c-string.

  15. basic_string(size_type n, CharT c);

    Effects: Constructs a basic_string with a default-constructed allocator, and is initialized by n copies of c.

  16. basic_string(size_type n, CharT c, const allocator_type & a);

    Effects: Constructs a basic_string taking the allocator as parameter, and is initialized by n copies of c.

  17. basic_string(size_type n, default_init_t);

    Effects: Constructs a basic_string with a default-constructed allocator, and is initialized by n default-initialized characters.

  18. basic_string(size_type n, default_init_t, const allocator_type & a);

    Effects: Constructs a basic_string taking the allocator as parameter, and is initialized by n default-initialized characters.

  19. template<typename InputIterator> 
      basic_string(InputIterator f, InputIterator l);

    Effects: Constructs a basic_string with a default-constructed allocator, and a range of iterators.

  20. template<typename InputIterator> 
      basic_string(InputIterator f, InputIterator l, const allocator_type & a);

    Effects: Constructs a basic_string taking the allocator as parameter, and a range of iterators.

  21. basic_string(std::initializer_list< value_type > il, 
                 const allocator_type & a = allocator_type());

    Effects: Same as basic_string(il.begin(), il.end(), a).

  22. basic_string & operator=(BOOST_COPY_ASSIGN_REF(basic_string) x);

    Effects: Copy constructs a string.

    Postcondition: x == *this.

    Complexity: Linear to the elements x contains.

  23. basic_string & operator=(BOOST_RV_REF(basic_string) x) noexcept(condition);

    Effects: Move constructor. Moves x's resources to *this.

    Throws: If allocator_traits_type::propagate_on_container_move_assignment is false and allocation throws

    Complexity: Constant if allocator_traits_type:: propagate_on_container_move_assignment is true or this->get>allocator() == x.get_allocator(). Linear otherwise.

  24. basic_string & operator=(const CharT * s);

    Effects: Assignment from a null-terminated c-string.

  25. basic_string & operator=(CharT c);

    Effects: Returns *this = basic_string(1, c).

  26. template<template< class, class > class BasicStringView> 
      basic_string & operator=(BasicStringView< CharT, Traits > sv);

    Effects: Equivalent to return assign(sv).

  27. basic_string & operator=(std::initializer_list< CharT > il);

    Effects: Returns *this = basic_string(il);

  28. ~basic_string();

    Effects: Destroys the basic_string. All used memory is deallocated.

    Throws: Nothing.

    Complexity: Constant.

basic_string public member functions

  1. typedef BOOST_CONTAINER_IMPDEF(allocator_type);
  2. typedef BOOST_CONTAINER_IMPDEF(pointer);
  3. typedef BOOST_CONTAINER_IMPDEF(const_pointer) const;
  4. typedef BOOST_CONTAINER_IMPDEF(boost::container::reverse_iterator< iterator >);
  5. typedef BOOST_CONTAINER_IMPDEF(boost::container::reverse_iterator< const_iterator >) const;
  6. allocator_type get_allocator() const;

    Effects: Returns a copy of the internal allocator.

    Throws: If allocator's copy constructor throws.

    Complexity: Constant.

  7. stored_allocator_type & get_stored_allocator();

    Effects: Returns a reference to the internal allocator.

    Throws: Nothing

    Complexity: Constant.

    Note: Non-standard extension.

  8. const stored_allocator_type & get_stored_allocator() const;

    Effects: Returns a reference to the internal allocator.

    Throws: Nothing

    Complexity: Constant.

    Note: Non-standard extension.

  9. iterator begin();

    Effects: Returns an iterator to the first element contained in the vector.

    Throws: Nothing.

    Complexity: Constant.

  10. const_iterator begin() const;

    Effects: Returns a const_iterator to the first element contained in the vector.

    Throws: Nothing.

    Complexity: Constant.

  11. iterator end();

    Effects: Returns an iterator to the end of the vector.

    Throws: Nothing.

    Complexity: Constant.

  12. const_iterator end() const;

    Effects: Returns a const_iterator to the end of the vector.

    Throws: Nothing.

    Complexity: Constant.

  13. reverse_iterator rbegin();

    Effects: Returns a reverse_iterator pointing to the beginning of the reversed vector.

    Throws: Nothing.

    Complexity: Constant.

  14. const_reverse_iterator rbegin() const;

    Effects: Returns a const_reverse_iterator pointing to the beginning of the reversed vector.

    Throws: Nothing.

    Complexity: Constant.

  15. reverse_iterator rend();

    Effects: Returns a reverse_iterator pointing to the end of the reversed vector.

    Throws: Nothing.

    Complexity: Constant.

  16. const_reverse_iterator rend() const;

    Effects: Returns a const_reverse_iterator pointing to the end of the reversed vector.

    Throws: Nothing.

    Complexity: Constant.

  17. const_iterator cbegin() const;

    Effects: Returns a const_iterator to the first element contained in the vector.

    Throws: Nothing.

    Complexity: Constant.

  18. const_iterator cend() const;

    Effects: Returns a const_iterator to the end of the vector.

    Throws: Nothing.

    Complexity: Constant.

  19. const_reverse_iterator crbegin() const;

    Effects: Returns a const_reverse_iterator pointing to the beginning of the reversed vector.

    Throws: Nothing.

    Complexity: Constant.

  20. const_reverse_iterator crend() const;

    Effects: Returns a const_reverse_iterator pointing to the end of the reversed vector.

    Throws: Nothing.

    Complexity: Constant.

  21. bool empty() const;

    Effects: Returns true if the vector contains no elements.

    Throws: Nothing.

    Complexity: Constant.

  22. size_type size() const;

    Effects: Returns the number of the elements contained in the vector.

    Throws: Nothing.

    Complexity: Constant.

  23. size_type length() const;

    Effects: Returns the number of the elements contained in the vector.

    Throws: Nothing.

    Complexity: Constant.

  24. size_type max_size() const;

    Effects: Returns the largest possible size of the vector.

    Throws: Nothing.

    Complexity: Constant.

  25. void resize(size_type n, CharT c);

    Effects: Inserts or erases elements at the end such that the size becomes n. New elements are copy constructed from x.

    Throws: If memory allocation throws

    Complexity: Linear to the difference between size() and new_size.

  26. void resize(size_type n);

    Effects: Inserts or erases elements at the end such that the size becomes n. New elements are value initialized.

    Throws: If memory allocation throws

    Complexity: Linear to the difference between size() and new_size.

  27. void resize(size_type n, default_init_t);

    Effects: Inserts or erases elements at the end such that the size becomes n. New elements are uninitialized.

    Throws: If memory allocation throws

    Complexity: Linear to the difference between size() and new_size.

    Note: Non-standard extension

  28. size_type capacity() const;

    Effects: Number of elements for which memory has been allocated. capacity() is always greater than or equal to size().

    Throws: Nothing.

    Complexity: Constant.

  29. void reserve(size_type res_arg);

    Effects: If n is less than or equal to capacity(), this call has no effect. Otherwise, it is a request for allocation of additional memory. If the request is successful, then capacity() is greater than or equal to n; otherwise, capacity() is unchanged. In either case, size() is unchanged.

    Throws: If memory allocation allocation throws

  30. void shrink_to_fit();

    Effects: Tries to deallocate the excess of memory created with previous allocations. The size of the string is unchanged

    Throws: Nothing

    Complexity: Linear to size().

  31. reference front();

    Requires: !empty()

    Effects: Returns a reference to the first element of the container.

    Throws: Nothing.

    Complexity: Constant.

  32. const_reference front() const;

    Requires: !empty()

    Effects: Returns a const reference to the first element of the container.

    Throws: Nothing.

    Complexity: Constant.

  33. reference back();

    Requires: !empty()

    Effects: Returns a reference to the last element of the container.

    Throws: Nothing.

    Complexity: Constant.

  34. const_reference back() const;

    Requires: !empty()

    Effects: Returns a const reference to the last element of the container.

    Throws: Nothing.

    Complexity: Constant.

  35. reference operator[](size_type n);

    Requires: size() > n.

    Effects: Returns a reference to the nth element from the beginning of the container.

    Throws: Nothing.

    Complexity: Constant.

  36. const_reference operator[](size_type n) const;

    Requires: size() > n.

    Effects: Returns a const reference to the nth element from the beginning of the container.

    Throws: Nothing.

    Complexity: Constant.

  37. reference at(size_type n);

    Requires: size() > n.

    Effects: Returns a reference to the nth element from the beginning of the container.

    Throws: std::range_error if n >= size()

    Complexity: Constant.

  38. const_reference at(size_type n) const;

    Requires: size() > n.

    Effects: Returns a const reference to the nth element from the beginning of the container.

    Throws: std::range_error if n >= size()

    Complexity: Constant.

  39. basic_string & operator+=(const basic_string & s);

    Effects: Calls append(str.data, str.size()).

    Returns: *this

  40. template<template< class, class > class BasicStringView> 
      basic_string & operator+=(BasicStringView< CharT, Traits > sv);

    Effects: Same as return append(sv).

  41. basic_string & operator+=(const CharT * s);

    Effects: Calls append(s).

    Returns: *this

  42. basic_string & operator+=(CharT c);

    Effects: Calls append(1, c).

    Returns: *this

  43. basic_string & operator+=(std::initializer_list< CharT > il);

    Effects: Returns append(il)

  44. basic_string & append(const basic_string & s);

    Effects: Calls append(str.data(), str.size()).

    Returns: *this

  45. template<template< class, class > class BasicStringView> 
      basic_string & append(BasicStringView< CharT, Traits > sv);

    Effects: Same as return append(sv.data(), sv.size()).

  46. basic_string & 
    append(const basic_string & s, size_type pos, size_type n = npos);

    Requires: pos <= str.size()

    Effects: Determines the effective length rlen of the string to append as the smaller of n and str.size() - pos and calls append(str.data() + pos, rlen).

    Throws: If memory allocation throws and out_of_range if pos > str.size()

    Returns: *this

  47. basic_string & append(const CharT * s, size_type n);

    Requires: s points to an array of at least n elements of CharT.

    Effects: The function replaces the string controlled by *this with a string of length size() + n whose irst size() elements are a copy of the original string controlled by *this and whose remaining elements are a copy of the initial n elements of s.

    Throws: If memory allocation throws length_error if size() + n > max_size().

    Returns: *this

  48. basic_string & append(const CharT * s);

    Requires: s points to an array of at least traits::length(s) + 1 elements of CharT.

    Effects: Calls append(s, traits::length(s)).

    Returns: *this

  49. basic_string & append(size_type n, CharT c);

    Effects: Equivalent to append(basic_string(n, c)).

    Returns: *this

  50. template<typename InputIter> 
      basic_string & append(InputIter first, InputIter last);

    Requires: [first,last) is a valid range.

    Effects: Equivalent to append(basic_string(first, last)).

    Returns: *this

  51. basic_string & append(std::initializer_list< CharT > il);

    Effects: Returns append(il.begin(), il.size()).

  52. void push_back(CharT c);

    Effects: Equivalent to append(static_cast<size_type>(1), c).

  53. basic_string & assign(const basic_string & s);

    Effects: Equivalent to assign(str, 0, npos).

    Returns: *this

  54. template<template< class, class > class BasicStringView> 
      basic_string & assign(BasicStringView< CharT, Traits > sv);

    Effects: Equivalent to return assign(sv.data(), sv.size()).

    Returns: *this

  55. basic_string & assign(BOOST_RV_REF(basic_string) ms);

    Effects: The function replaces the string controlled by *this with a string of length str.size() whose elements are a copy of the string controlled by str. Leaves str in a valid but unspecified state.

    Throws: Nothing

    Returns: *this

  56. basic_string & assign(const basic_string & s, size_type pos, size_type n);

    Requires: pos <= str.size()

    Effects: Determines the effective length rlen of the string to assign as the smaller of n and str.size() - pos and calls assign(str.data() + pos rlen).

    Throws: If memory allocation throws or out_of_range if pos > str.size().

    Returns: *this

  57. basic_string & assign(const CharT * s, size_type n);

    Requires: s points to an array of at least n elements of CharT.

    Effects: Replaces the string controlled by *this with a string of length n whose elements are a copy of those pointed to by s.

    Throws: If memory allocation throws or length_error if n > max_size().

    Returns: *this

  58. basic_string & assign(const CharT * s);

    Requires: s points to an array of at least traits::length(s) + 1 elements of CharT.

    Effects: Calls assign(s, traits::length(s)).

    Returns: *this

  59. basic_string & assign(size_type n, CharT c);

    Effects: Equivalent to assign(basic_string(n, c)).

    Returns: *this

  60. basic_string & assign(const CharT * first, const CharT * last);

    Effects: Equivalent to assign(basic_string(first, last)). Returns: *this

  61. template<typename InputIter> 
      basic_string & 
      assign(InputIter first, InputIter last #if ! defined, 
             typename dtl::disable_if_convertible< InputIter, size_type >::type * = 0 #endif);

    Effects: Equivalent to assign(basic_string(first, last)).

    Returns: *this

  62. basic_string & assign(std::initializer_list< CharT > il);

    Effects: Returns assign(il.begin(), il.size()).

  63. basic_string & insert(size_type pos, const basic_string & s);

    Requires: pos <= size().

    Effects: Calls insert(pos, str.data(), str.size()).

    Throws: If memory allocation throws or out_of_range if pos > size().

    Returns: *this

  64. basic_string & 
    insert(size_type pos1, const basic_string & s, size_type pos2, 
           size_type n = npos);

    Requires: pos1 <= size() and pos2 <= str.size()

    Effects: Determines the effective length rlen of the string to insert as the smaller of n and str.size() - pos2 and calls insert(pos1, str.data() + pos2, rlen).

    Throws: If memory allocation throws or out_of_range if pos1 > size() or pos2 > str.size().

    Returns: *this

  65. basic_string & insert(size_type pos, const CharT * s, size_type n);

    Requires: s points to an array of at least n elements of CharT and pos <= size().

    Effects: Replaces the string controlled by *this with a string of length size() + n whose first pos elements are a copy of the initial elements of the original string controlled by *this and whose next n elements are a copy of the elements in s and whose remaining elements are a copy of the remaining elements of the original string controlled by *this.

    Throws: If memory allocation throws, out_of_range if pos > size() or length_error if size() + n > max_size().

    Returns: *this

  66. basic_string & insert(size_type pos, const CharT * s);

    Requires: pos <= size() and s points to an array of at least traits::length(s) + 1 elements of CharT

    Effects: Calls insert(pos, s, traits::length(s)).

    Throws: If memory allocation throws, out_of_range if pos > size() length_error if size() > max_size() - Traits::length(s)

    Returns: *this

  67. basic_string & insert(size_type pos, size_type n, CharT c);

    Effects: Equivalent to insert(pos, basic_string(n, c)).

    Throws: If memory allocation throws, out_of_range if pos > size() length_error if size() > max_size() - n

    Returns: *this

  68. template<template< class, class > class BasicStringView> 
      basic_string & insert(size_type pos, BasicStringView< CharT, Traits > sv);

    Effects: Same as return insert(pos, sv.data(), sv.size()).

  69. iterator insert(const_iterator p, CharT c);

    Requires: p is a valid iterator on *this.

    Effects: inserts a copy of c before the character referred to by p.

    Returns: An iterator which refers to the copy of the inserted character.

  70. iterator insert(const_iterator p, size_type n, CharT c);

    Requires: p is a valid iterator on *this.

    Effects: Inserts n copies of c before the character referred to by p.

    Returns: an iterator to the first inserted element or p if n is 0.

  71. template<typename InputIter> 
      iterator insert(const_iterator p, InputIter first, 
                      InputIter last #if ! defined, 
                      typename dtl::disable_if_or< void, dtl::is_convertible< InputIter, size_type >, dtl::is_not_input_iterator< InputIter > >::type * = 0 #endif);

    Requires: p is a valid iterator on *this. [first,last) is a valid range.

    Effects: Equivalent to insert(p - begin(), basic_string(first, last)).

    Returns: an iterator to the first inserted element or p if first == last.

  72. template<typename ForwardIter> 
      iterator insert(const_iterator p, ForwardIter first, ForwardIter last, 
                      typename dtl::disable_if_or< void, dtl::is_convertible< ForwardIter, size_type >, dtl::is_input_iterator< ForwardIter > >::type * = 0);
  73. iterator insert(const_iterator p, std::initializer_list< CharT > il);

    Effects: As if by insert(p, il.begin(), il.end()).

    Returns: An iterator which refers to the copy of the first inserted character, or p if i1 is empty.

  74. void pop_back();

    Effects: Removes the last element from the container.

    Throws: Nothing.

    Complexity: Constant time.

  75. basic_string & erase(size_type pos = 0, size_type n = npos);

    Requires: pos <= size()

    Effects: Determines the effective length xlen of the string to be removed as the smaller of n and size() - pos. The function then replaces the string controlled by *this with a string of length size() - xlen whose first pos elements are a copy of the initial elements of the original string controlled by *this, and whose remaining elements are a copy of the elements of the original string controlled by *this beginning at position pos + xlen.

    Throws: out_of_range if pos > size().

    Returns: *this

  76. iterator erase(const_iterator p);

    Effects: Removes the character referred to by p.

    Throws: Nothing

    Returns: An iterator which points to the element immediately following p prior to the element being erased. If no such element exists, end() is returned.

  77. iterator erase(const_iterator first, const_iterator last);

    Requires: first and last are valid iterators on *this, defining a range [first,last).

    Effects: Removes the characters in the range [first,last).

    Throws: Nothing

    Returns: An iterator which points to the element pointed to by last prior to the other elements being erased. If no such element exists, end() is returned.

  78. void clear();

    Effects: Erases all the elements of the vector.

    Throws: Nothing.

    Complexity: Linear to the number of elements in the vector.

  79. basic_string & replace(size_type pos1, size_type n1, const basic_string & str);

    Requires: pos1 <= size().

    Effects: Calls replace(pos1, n1, str.data(), str.size()).

    Throws: if memory allocation throws or out_of_range if pos1 > size().

    Returns: *this

  80. template<template< class, class > class BasicStringView> 
      basic_string & 
      replace(size_type pos1, size_type n1, BasicStringView< CharT, Traits > sv);

    Effects: Calls return replace(pos1, n1, sv.data(), sv.size());.

  81. basic_string & 
    replace(size_type pos1, size_type n1, const basic_string & str, 
            size_type pos2, size_type n2 = npos);

    Requires: pos1 <= size() and pos2 <= str.size().

    Effects: Determines the effective length rlen of the string to be inserted as the smaller of n2 and str.size() - pos2 and calls replace(pos1, n1, str.data() + pos2, rlen).

    Throws: if memory allocation throws, out_of_range if pos1 > size() or pos2 > str.size().

    Returns: *this

  82. template<template< class, class > class BasicStringView> 
      basic_string & 
      replace(size_type pos1, size_type n1, BasicStringView< CharT, Traits > sv, 
              size_type pos2, size_type n2 = npos);

    Throws: out_of_range if pos1 > size() or pos2 > sv.size().

    Effects: Determines the effective length rlen of the string to be inserted as the smaller of n2 and sv.size() - pos2 and calls replace(pos1, n1, sv.data() + pos2, rlen).

    Returns: *this.

  83. basic_string & 
    replace(size_type pos1, size_type n1, const CharT * s, size_type n2);

    Requires: pos1 <= size() and s points to an array of at least n2 elements of CharT.

    Effects: Determines the effective length xlen of the string to be removed as the smaller of n1 and size() - pos1. If size() - xlen >= max_size() - n2 throws length_error. Otherwise, the function replaces the string controlled by *this with a string of length size() - xlen + n2 whose first pos1 elements are a copy of the initial elements of the original string controlled by *this, whose next n2 elements are a copy of the initial n2 elements of s, and whose remaining elements are a copy of the elements of the original string controlled by *this beginning at position pos + xlen.

    Throws: if memory allocation throws, out_of_range if pos1 > size() or length_error if the length of the resulting string would exceed max_size()

    Returns: *this

  84. basic_string & replace(size_type pos, size_type n1, const CharT * s);

    Requires: pos1 <= size() and s points to an array of at least n2 elements of CharT.

    Effects: Determines the effective length xlen of the string to be removed as the smaller of n1 and size() - pos1. If size() - xlen >= max_size() - n2 throws length_error. Otherwise, the function replaces the string controlled by *this with a string of length size() - xlen + n2 whose first pos1 elements are a copy of the initial elements of the original string controlled by *this, whose next n2 elements are a copy of the initial n2 elements of s, and whose remaining elements are a copy of the elements of the original string controlled by *this beginning at position pos + xlen.

    Throws: if memory allocation throws, out_of_range if pos1 > size() or length_error if the length of the resulting string would exceed max_size()

    Returns: *this

  85. basic_string & replace(size_type pos1, size_type n1, size_type n2, CharT c);

    Requires: pos1 <= size().

    Effects: Equivalent to replace(pos1, n1, basic_string(n2, c)).

    Throws: if memory allocation throws, out_of_range if pos1 > size() or length_error if the length of the resulting string would exceed max_size()

    Returns: *this

  86. basic_string & 
    replace(const_iterator i1, const_iterator i2, const basic_string & str);

    Requires: [begin(),i1) and [i1,i2) are valid ranges.

    Effects: Calls replace(i1 - begin(), i2 - i1, str).

    Throws: if memory allocation throws

    Returns: *this

  87. basic_string & 
    replace(const_iterator i1, const_iterator i2, const CharT * s, size_type n);

    Requires: [begin(),i1) and [i1,i2) are valid ranges and s points to an array of at least n elements

    Effects: Calls replace(i1 - begin(), i2 - i1, s, n).

    Throws: if memory allocation throws

    Returns: *this

  88. basic_string & replace(const_iterator i1, const_iterator i2, const CharT * s);

    Requires: [begin(),i1) and [i1,i2) are valid ranges and s points to an array of at least traits::length(s) + 1 elements of CharT.

    Effects: Calls replace(i1 - begin(), i2 - i1, s, traits::length(s)).

    Throws: if memory allocation throws

    Returns: *this

  89. basic_string & 
    replace(const_iterator i1, const_iterator i2, size_type n, CharT c);

    Requires: [begin(),i1) and [i1,i2) are valid ranges.

    Effects: Calls replace(i1 - begin(), i2 - i1, basic_string(n, c)).

    Throws: if memory allocation throws

    Returns: *this

  90. template<typename InputIter> 
      basic_string & 
      replace(const_iterator i1, const_iterator i2, InputIter j1, 
              InputIter j2 #if ! defined, 
              typename dtl::disable_if_or< void, dtl::is_convertible< InputIter, size_type >, dtl::is_input_iterator< InputIter > >::type * = 0 #endif);

    Requires: [begin(),i1), [i1,i2) and [j1,j2) are valid ranges.

    Effects: Calls replace(i1 - begin(), i2 - i1, basic_string(j1, j2)).

    Throws: if memory allocation throws

    Returns: *this

  91. template<typename ForwardIter> 
      basic_string & 
      replace(const_iterator i1, const_iterator i2, ForwardIter j1, 
              ForwardIter j2, 
              typename dtl::disable_if_or< void, dtl::is_convertible< ForwardIter, size_type >, dtl::is_not_input_iterator< ForwardIter > >::type * = 0);
  92. template<template< class, class > class BasicStringView> 
      basic_string & 
      replace(const_iterator i1, const_iterator i2, 
              BasicStringView< CharT, Traits > sv);

    Requires: [begin(), i1) and [i1, i2) are valid ranges.

    Effects: Calls replace(i1 - begin(), i2 - i1, sv)..

    Returns: *this.

  93. basic_string & 
    replace(const_iterator i1, const_iterator i2, 
            std::initializer_list< CharT > il);

    Requires: [begin(), i1) and [i1, i2) are valid ranges.

    Effects: Calls replace(i1 - begin(), i2 - i1, il.begin(), il.size()).

    Returns: *this.

  94. size_type copy(CharT * s, size_type n, size_type pos = 0) const;

    Requires: pos <= size()

    Effects: Determines the effective length rlen of the string to copy as the smaller of n and size() - pos. s shall designate an array of at least rlen elements. The function then replaces the string designated by s with a string of length rlen whose elements are a copy of the string controlled by *this beginning at position pos. The function does not append a null object to the string designated by s.

    Throws: if memory allocation throws, out_of_range if pos > size().

    Returns: rlen

  95. void swap(basic_string & x) noexcept(condition);

    Effects: *this contains the same sequence of characters that was in s, s contains the same sequence of characters that was in *this.

    Throws: Nothing

  96. const CharT * c_str() const;

    Requires: The program shall not alter any of the values stored in the character array.

    Returns: A pointer p such that p + i == &operator[](i) for each i in [0,size()].

    Complexity: constant time.

  97. const CharT * data() const;

    Requires: The program shall not alter any of the values stored in the character array.

    Returns: A pointer p such that p + i == &operator[](i) for each i in [0,size()].

    Complexity: constant time.

  98. CharT * data();

    Returns: A pointer p such that p + i == &operator[](i) for each i in [0,size()].

    Complexity: constant time.

  99. template<template< class, class > class BasicStringView> 
      operator BasicStringView< CharT, Traits >() const;

    Returns: a string_view to the characters in the string.

    Complexity: constant time.

  100. template<typename BasicStringView> BasicStringView to_view() const;

    Returns: a string_view to the characters in the string.

    Complexity: constant time.

    Note: This function is available to write portable code for compilers that don't support templated conversion operators.

  101. size_type find(const basic_string & s, size_type pos = 0) const;

    Effects: Determines the lowest position xpos, if possible, such that both of the following conditions hold: 1) pos <= xpos and xpos + str.size() <= size(); 2) traits::eq(at(xpos+I), str.at(I)) for all elements I of the string controlled by str.

    Throws: Nothing

    Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.

  102. template<template< class, class > class BasicStringView> 
      size_type find(BasicStringView< CharT, Traits > sv, size_type pos = 0) const;

    Effects: Determines the lowest position xpos, if possible, such that both of the following conditions hold: 1) pos <= xpos and xpos + sv.size() <= size(); 2) traits::eq(at(xpos+I), sv.at(I)) for all elements I of the string controlled by sv.

    Throws: Nothing

    Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.

  103. size_type find(const CharT * s, size_type pos, size_type n) const;

    Requires: s points to an array of at least n elements of CharT.

    Throws: Nothing

    Returns: find(basic_string<CharT,traits,allocator_type>(s,n),pos).

  104. size_type find(const CharT * s, size_type pos = 0) const;

    Requires: s points to an array of at least traits::length(s) + 1 elements of CharT.

    Throws: Nothing

    Returns: find(basic_string(s), pos).

  105. size_type find(CharT c, size_type pos = 0) const;

    Throws: Nothing

    Returns: find(basic_string<CharT,traits,allocator_type>(1,c), pos).

  106. size_type rfind(const basic_string & str, size_type pos = npos) const;

    Effects: Determines the highest position xpos, if possible, such that both of the following conditions obtain: a) xpos <= pos and xpos + str.size() <= size(); b) traits::eq(at(xpos+I), str.at(I)) for all elements I of the string controlled by str.

    Throws: Nothing

    Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.

  107. template<template< class, class > class BasicStringView> 
      size_type rfind(BasicStringView< CharT, Traits > sv, size_type pos = npos) const;

    Effects: Determines the highest position xpos, if possible, such that both of the following conditions obtain: a) xpos <= pos and xpos + sv.size() <= size(); b) traits::eq(at(xpos+I), sv.at(I)) for all elements I of the string controlled by sv.

    Throws: Nothing

    Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.

  108. size_type rfind(const CharT * s, size_type pos, size_type n) const;

    Requires: s points to an array of at least n elements of CharT.

    Throws: Nothing

    Returns: rfind(basic_string(s, n), pos).

  109. size_type rfind(const CharT * s, size_type pos = npos) const;

    Requires: pos <= size() and s points to an array of at least traits::length(s) + 1 elements of CharT.

    Throws: Nothing

    Returns: rfind(basic_string(s), pos).

  110. size_type rfind(CharT c, size_type pos = npos) const;

    Throws: Nothing

    Returns: rfind(basic_string<CharT,traits,allocator_type>(1,c),pos).

  111. size_type find_first_of(const basic_string & str, size_type pos = 0) const;

    Effects: Determines the lowest position xpos, if possible, such that both of the following conditions obtain: a) pos <= xpos and xpos < size(); b) traits::eq(at(xpos), str.at(I)) for some element I of the string controlled by str.

    Throws: Nothing

    Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.

  112. template<template< class, class > class BasicStringView> 
      size_type find_first_of(BasicStringView< CharT, Traits > sv, 
                              size_type pos = 0) const;

    Effects: Determines the lowest position xpos, if possible, such that both of the following conditions obtain: a) pos <= xpos and xpos < size(); b) traits::eq(at(xpos), sv.at(I)) for some element I of the string controlled by sv.

    Throws: Nothing

    Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.

  113. size_type find_first_of(const CharT * s, size_type pos, size_type n) const;

    Requires: s points to an array of at least n elements of CharT.

    Throws: Nothing

    Returns: find_first_of(basic_string(s, n), pos).

  114. size_type find_first_of(const CharT * s, size_type pos = 0) const;

    Requires: s points to an array of at least traits::length(s) + 1 elements of CharT.

    Throws: Nothing

    Returns: find_first_of(basic_string(s), pos).

  115. size_type find_first_of(CharT c, size_type pos = 0) const;

    Requires: s points to an array of at least traits::length(s) + 1 elements of CharT.

    Throws: Nothing

    Returns: find_first_of(basic_string<CharT,traits,allocator_type>(1,c), pos).

  116. size_type find_last_of(const basic_string & str, size_type pos = npos) const;

    Effects: Determines the highest position xpos, if possible, such that both of the following conditions obtain: a) xpos <= pos and xpos < size(); b) traits::eq(at(xpos), str.at(I)) for some element I of the string controlled by str.

    Throws: Nothing

    Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.

  117. template<template< class, class > class BasicStringView> 
      size_type find_last_of(BasicStringView< CharT, Traits > sv, 
                             size_type pos = npos) const;

    Effects: Determines the highest position xpos, if possible, such that both of the following conditions obtain: a) xpos <= pos and xpos < size(); b) traits::eq(at(xpos), str.at(I)) for some element I of the string controlled by str.

    Throws: Nothing

    Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.

  118. size_type find_last_of(const CharT * s, size_type pos, size_type n) const;

    Requires: s points to an array of at least n elements of CharT.

    Throws: Nothing

    Returns: find_last_of(basic_string(s, n), pos).

  119. size_type find_last_of(const CharT * s, size_type pos = npos) const;

    Requires: s points to an array of at least traits::length(s) + 1 elements of CharT.

    Throws: Nothing

    Returns: find_last_of(basic_string<CharT,traits,allocator_type>(1,c),pos).

  120. size_type find_last_of(CharT c, size_type pos = npos) const;

    Throws: Nothing

    Returns: find_last_of(basic_string(s), pos).

  121. size_type find_first_not_of(const basic_string & str, size_type pos = 0) const;

    Effects: Determines the lowest position xpos, if possible, such that both of the following conditions obtain: a) pos <= xpos and xpos < size(); b) traits::eq(at(xpos), str.at(I)) for no element I of the string controlled by str.

    Throws: Nothing

    Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.

  122. template<template< class, class > class BasicStringView> 
      size_type find_first_not_of(BasicStringView< CharT, Traits > sv, 
                                  size_type pos = 0) const;

    Effects: Determines the lowest position xpos, if possible, such that both of the following conditions obtain: a) pos <= xpos and xpos < size(); b) traits::eq(at(xpos), sv.at(I)) for no element I of the string controlled by sv.

    Throws: Nothing

    Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.

  123. size_type find_first_not_of(const CharT * s, size_type pos, size_type n) const;

    Requires: s points to an array of at least traits::length(s) + 1 elements of CharT.

    Throws: Nothing

    Returns: find_first_not_of(basic_string(s, n), pos).

  124. size_type find_first_not_of(const CharT * s, size_type pos = 0) const;

    Requires: s points to an array of at least traits::length(s) + 1 elements of CharT.

    Throws: Nothing

    Returns: find_first_not_of(basic_string(s), pos).

  125. size_type find_first_not_of(CharT c, size_type pos = 0) const;

    Throws: Nothing

    Returns: find_first_not_of(basic_string(1, c), pos).

  126. size_type find_last_not_of(const basic_string & str, size_type pos = npos) const;

    Effects: Determines the highest position xpos, if possible, such that both of the following conditions obtain: a) xpos <= pos and xpos < size(); b) traits::eq(at(xpos), str.at(I)) for no element I of the string controlled by str.

    Throws: Nothing

    Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.

  127. template<template< class, class > class BasicStringView> 
      size_type find_last_not_of(BasicStringView< CharT, Traits > sv, 
                                 size_type pos = npos) const;

    Effects: Determines the highest position xpos, if possible, such that both of the following conditions obtain: a) xpos <= pos and xpos < size(); b) traits::eq(at(xpos), sv.at(I)) for no element I of the string controlled by sv.

    Throws: Nothing

    Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.

  128. size_type find_last_not_of(const CharT * s, size_type pos, size_type n) const;

    Requires: s points to an array of at least n elements of CharT.

    Throws: Nothing

    Returns: find_last_not_of(basic_string(s, n), pos).

  129. size_type find_last_not_of(const CharT * s, size_type pos = npos) const;

    Requires: s points to an array of at least traits::length(s) + 1 elements of CharT.

    Throws: Nothing

    Returns: find_last_not_of(basic_string(s), pos).

  130. size_type find_last_not_of(CharT c, size_type pos = npos) const;

    Throws: Nothing

    Returns: find_last_not_of(basic_string(1, c), pos).

  131. basic_string substr(size_type pos = 0, size_type n = npos) const;

    Requires: Requires: pos <= size()

    Effects: Determines the effective length rlen of the string to copy as the smaller of n and size() - pos.

    Throws: If memory allocation throws or out_of_range if pos > size().

    Returns: basic_string<CharT,traits,allocator_type>(data()+pos,rlen).

  132. int compare(const basic_string & str) const;

    Effects: Determines the effective length rlen of the string to compare as the smaller of size() and str.size(). The function then compares the two strings by calling traits::compare(data(), str.data(), rlen).

    Throws: Nothing

    Returns: The nonzero result if the result of the comparison is nonzero. Otherwise, returns a value < 0 if size() < str.size(), a 0 value if size() == str.size(), and value > 0 if size() > str.size()

  133. template<template< class, class > class BasicStringView> 
      int compare(BasicStringView< CharT, Traits > sv) const;

    Throws: Nothing

    Returns: compare(basic_string(sv)).

  134. int compare(size_type pos1, size_type n1, const basic_string & str) const;

    Requires: pos1 <= size()

    Effects: Determines the effective length rlen of the string to compare as the smaller of (this->size() - pos1), n1 and str.size(). The function then compares the two strings by calling traits::compare(data()+pos1, str.data(), rlen).

    Throws: out_of_range if pos1 > size()

    Returns:basic_string(*this,pos1,n1).compare(str).

  135. template<template< class, class > class BasicStringView> 
      int compare(size_type pos1, size_type n1, 
                  BasicStringView< CharT, Traits > sv) const;

    Requires: pos1 <= size()

    Throws: out_of_range if pos1 > size()

    Returns:basic_string(*this,pos1,n1).compare(sv).

  136. int compare(size_type pos1, size_type n1, const basic_string & str, 
                size_type pos2, size_type n2 = npos) const;

    Requires: pos1 <= size() and pos2 <= str.size()

    Effects: Determines the effective length rlen of the string to copy as the smaller of

    Throws: out_of_range if pos1 > size() or pos2 > str.size()

    Returns: basic_string(*this, pos1, n1).compare(basic_string(str, pos2, n2)).

  137. template<template< class, class > class BasicStringView> 
      int compare(size_type pos1, size_type n1, 
                  BasicStringView< CharT, Traits > sv, size_type pos2, 
                  size_type n2) const;

    Requires: pos1 <= size() and pos2 <= str.size()

    Effects: Determines the effective length rlen of the string to copy as the smaller of

    Throws: out_of_range if pos1 > size() or pos2 > sv.size()

    Returns: basic_string(*this, pos1, n1).compare(BasicStringView<CharT, Traits>(sv, pos2, n2)).

  138. int compare(const CharT * s) const;

    Throws: Nothing

    Returns: compare(basic_string(s)).

  139. int compare(size_type pos1, size_type n1, const CharT * s, size_type n2) const;

    Requires: pos1 > size() and s points to an array of at least n2 elements of CharT.

    Throws: out_of_range if pos1 > size()

    Returns: basic_string(*this, pos, n1).compare(basic_string(s, n2)).

  140. int compare(size_type pos1, size_type n1, const CharT * s) const;

    Requires: pos1 > size() and s points to an array of at least traits::length(s) + 1 elements of CharT.

    Throws: out_of_range if pos1 > size()

    Returns: basic_string(*this, pos, n1).compare(basic_string(s, n2)).

basic_string private member functions

  1. void priv_reserve(size_type res_arg, const bool null_terminate = true);
  2. template<typename AllocVersion> 
      void priv_shrink_to_fit_dynamic_buffer(AllocVersion, 
                                             typename dtl::enable_if< dtl::is_same< AllocVersion, version_1 > >::type * = 0);
  3. template<typename AllocVersion> 
      void priv_shrink_to_fit_dynamic_buffer(AllocVersion, 
                                             typename dtl::enable_if< dtl::is_same< AllocVersion, version_2 > >::type * = 0);
  4. void priv_construct_null(pointer p);
  5. void priv_terminate_string();
  6. template<typename FwdIt, typename Count> 
      void priv_uninitialized_fill_n(FwdIt first, Count count, const CharT val);
  7. template<typename InpIt, typename FwdIt> 
      size_type priv_uninitialized_copy(InpIt first, InpIt last, FwdIt dest);
  8. template<typename InputIterator, typename OutIterator> 
      void priv_copy(InputIterator first, InputIterator last, OutIterator result);
  9. void priv_copy(const CharT * first, const CharT * last, CharT * result);
  10. template<typename Integer> 
      basic_string & 
      priv_replace_dispatch(const_iterator first, const_iterator last, Integer n, 
                            Integer x, dtl::true_);
  11. template<typename InputIter> 
      basic_string & 
      priv_replace_dispatch(const_iterator first, const_iterator last, 
                            InputIter f, InputIter l, dtl::false_);

basic_string private static functions

  1. template<typename It1, typename It2> 
      static int s_compare(It1 f1, It1 l1, It2 f2, It2 l2);

PrevUpHomeNext