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

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Class template basic_string

boost::compute::basic_string — A template for a dynamically-sized character sequence.

Synopsis

// In header: <boost/compute/container/basic_string.hpp>

template<typename CharT, typename Traits = std::char_traits<CharT> > 
class basic_string {
public:
  // types
  typedef Traits                                                    traits_type;           
  typedef Traits::char_type                                         value_type;            
  typedef size_t                                                    size_type;             
  typedef ::boost::compute::vector< CharT >::reference              reference;             
  typedef ::boost::compute::vector< CharT >::const_reference        const_reference;       
  typedef ::boost::compute::vector< CharT >::iterator               iterator;              
  typedef ::boost::compute::vector< CharT >::const_iterator         const_iterator;        
  typedef ::boost::compute::vector< CharT >::reverse_iterator       reverse_iterator;      
  typedef ::boost::compute::vector< CharT >::const_reverse_iterator const_reverse_iterator;

  // construct/copy/destruct
  basic_string();
  basic_string(size_type, CharT);
  basic_string(const basic_string &, size_type, size_type = npos);
  basic_string(const char *, size_type);
  basic_string(const char *);
  template<typename InputIterator> basic_string(InputIterator, InputIterator);
  basic_string(const basic_string< CharT, Traits > &);
  basic_string< CharT, Traits > & 
  operator=(const basic_string< CharT, Traits > &);
  ~basic_string();

  // public member functions
  reference at(size_type);
  const_reference at(size_type) const;
  reference operator[](size_type);
  const_reference operator[](size_type) const;
  reference front();
  const_reference front() const;
  reference back();
  const_reference back() const;
  iterator begin();
  const_iterator begin() const;
  const_iterator cbegin() const;
  iterator end();
  const_iterator end() const;
  const_iterator cend() const;
  reverse_iterator rbegin();
  const_reverse_iterator rbegin() const;
  const_reverse_iterator crbegin() const;
  reverse_iterator rend();
  const_reverse_iterator rend() const;
  const_reverse_iterator crend() const;
  bool empty() const;
  size_type size() const;
  size_type length() const;
  size_type max_size() const;
  void reserve(size_type);
  size_type capacity() const;
  void shrink_to_fit();
  void clear();
  void swap(basic_string< CharT, Traits > &);
  basic_string< CharT, Traits > substr(size_type = 0, size_type = npos) const;
  size_type find(CharT, size_type = 0) const;
  size_type find(basic_string &, size_type = 0) const;
  size_type find(const char *, size_type = 0) const;

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

Description

The basic_string class provides a generic template for a dynamically- sized character sequence. This is most commonly used through the string typedef (for basic_string<char>).

For example, to create a string on the device with its contents copied from a C-string on the host:

boost::compute::string str("hello, world!");

See Also:

vector<T>

basic_string public construct/copy/destruct

  1. basic_string();
  2. basic_string(size_type count, CharT ch);
  3. basic_string(const basic_string & other, size_type pos, 
                 size_type count = npos);
  4. basic_string(const char * s, size_type count);
  5. basic_string(const char * s);
  6. template<typename InputIterator> 
      basic_string(InputIterator first, InputIterator last);
  7. basic_string(const basic_string< CharT, Traits > & other);
  8. basic_string< CharT, Traits > & 
    operator=(const basic_string< CharT, Traits > & other);
  9. ~basic_string();

basic_string public member functions

  1. reference at(size_type pos);
  2. const_reference at(size_type pos) const;
  3. reference operator[](size_type pos);
  4. const_reference operator[](size_type pos) const;
  5. reference front();
  6. const_reference front() const;
  7. reference back();
  8. const_reference back() const;
  9. iterator begin();
  10. const_iterator begin() const;
  11. const_iterator cbegin() const;
  12. iterator end();
  13. const_iterator end() const;
  14. const_iterator cend() const;
  15. reverse_iterator rbegin();
  16. const_reverse_iterator rbegin() const;
  17. const_reverse_iterator crbegin() const;
  18. reverse_iterator rend();
  19. const_reverse_iterator rend() const;
  20. const_reverse_iterator crend() const;
  21. bool empty() const;
  22. size_type size() const;
  23. size_type length() const;
  24. size_type max_size() const;
  25. void reserve(size_type size);
  26. size_type capacity() const;
  27. void shrink_to_fit();
  28. void clear();
  29. void swap(basic_string< CharT, Traits > & other);
  30. basic_string< CharT, Traits > 
    substr(size_type pos = 0, size_type count = npos) const;
  31. size_type find(CharT ch, size_type pos = 0) const;
    Finds the first character ch.
  32. size_type find(basic_string & str, size_type pos = 0) const;
    Finds the first substring equal to str.
  33. size_type find(const char * s, size_type pos = 0) const;

    Finds the first substring equal to the character string pointed to by s. The length of the string is determined by the first null character.

    For example, the following code

    
    

    will return 5 as position.


PrevUpHomeNext