![]() |
Home | Libraries | People | FAQ | More |
boost::compute::basic_string — A template for a dynamically-sized character sequence.
// 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; };
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:
basic_string
public
construct/copy/destructbasic_string();
basic_string(size_type count, CharT ch);
basic_string(const basic_string & other, size_type pos, size_type count = npos);
basic_string(const char * s, size_type count);
basic_string(const char * s);
template<typename InputIterator> basic_string(InputIterator first, InputIterator last);
basic_string(const basic_string< CharT, Traits > & other);
basic_string< CharT, Traits > & operator=(const basic_string< CharT, Traits > & other);
~basic_string();
basic_string public member functionsreference at(size_type pos);
const_reference at(size_type pos) const;
reference operator[](size_type pos);
const_reference operator[](size_type pos) 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);
size_type capacity() const;
void shrink_to_fit();
void clear();
void swap(basic_string< CharT, Traits > & other);
basic_string< CharT, Traits > substr(size_type pos = 0, size_type count = npos) const;
size_type find(CharT ch, size_type pos = 0) const;Finds the first character
ch. size_type find(basic_string & str, size_type pos = 0) const;Finds the first substring equal to
str. 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.