Sprout/source/libs/string/basic_string/index.rst

405 lines
17 KiB
ReStructuredText
Raw Normal View History

2013-09-06 14:27:44 +09:00
.. _sprout-string-basic_string:
2014-08-15 21:27:31 +09:00
2013-09-06 14:27:44 +09:00
###############################################################################
basic_string
###############################################################################
.. toctree::
:hidden:
constructor-
operator-assign
begin
end
rbegin
rend
cbegin
cend
crbegin
crend
size
length
max_size
resize
clear
empty
operator-subscript
at
front
back
assign
swap
data
c_array
data
find
rfind
find_first_of
find_last_of
find_first_not_of
find_last_not_of
substr
compare
operator-std-basic_string
operator-assign-iterator
assign-iterator
find-iterator
rfind-iterator
find_first_of-iterator
find_last_of-iterator
find_first_not_of-iterator
find_last_not_of-iterator
compare-iterator
Interface
========================================
.. sourcecode:: c++
template <typename T, std::size_t N, typename Traits = sprout::char_traits<T> >
class basic_string;
Description
========================================
Member types
----------------------------------------
2014-08-15 21:27:31 +09:00
.. csv-table::
:header: type, definition, note
:widths: 4, 4, 4
traits_type, Traits, ""
value_type, Traits::char_type, ""
size_type, std::size_t, ""
difference_type, std::ptrdiff_t, ""
reference, value_type&, ""
const_reference, value_type const&, ""
pointer, value_type*, ""
const_pointer, value_type const*, ""
iterator, **ConstexprRandomAccessIterator**, "| convertible to const_iterator
convertible to pointer"
const_iterator, **ConstexprRandomAccessIterator**, convertible to const_pointer
reverse_iterator, "| sprout::reverse_iterator<iterator>
**ConstexprRandomAccessIterator**", ""
const_reverse_iterator, "| sprout::reverse_iterator<const_iterator>
**ConstexprRandomAccessIterator**", ""
2013-09-06 14:27:44 +09:00
Member functions
----------------------------------------
construct/copy/destroy
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2014-08-15 21:27:31 +09:00
.. csv-table::
:header: function
:widths: 4, 8
:doc:`(constructor) <./constructor->`, ""
:doc:`operator= <./operator-assign>`, ""
2013-09-06 14:27:44 +09:00
iterators
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2014-08-15 21:27:31 +09:00
.. csv-table::
:header: function
:widths: 4, 8
:doc:`begin <./begin>`, ""
:doc:`end <./end>`, ""
:doc:`rbegin <./rbegin>`, ""
:doc:`rend <./rend>`, ""
:doc:`cbegin <./cbegin>`, ""
:doc:`cend <./cend>`, ""
:doc:`crbegin <./crbegin>`, ""
:doc:`crend <./crend>`, ""
2013-09-06 14:27:44 +09:00
capacity
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2014-08-15 21:27:31 +09:00
.. csv-table::
:header: function
:widths: 4, 8
:doc:`size <./size>`, ""
:doc:`length <./length>`, ""
:doc:`max_size <./max_size>`, ""
:doc:`resize <./resize>`, ""
:doc:`clear <./clear>`, ""
:doc:`empty <./empty>`, ""
2013-09-06 14:27:44 +09:00
element access
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2014-08-15 21:27:31 +09:00
.. csv-table::
:header: function
:widths: 4, 8
:doc:`operator[] <./operator-subscript>`, ""
:doc:`at <./at>`, ""
:doc:`front <./front>`, ""
:doc:`back <./back>`, ""
2013-09-06 14:27:44 +09:00
modifiers
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2014-08-15 21:27:31 +09:00
.. csv-table::
:header: function
:widths: 4, 8
:doc:`assign <./assign>`, ""
:doc:`swap <./swap>`, ""
2013-09-06 14:27:44 +09:00
string operations
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2014-08-15 21:27:31 +09:00
.. csv-table::
:header: function
:widths: 4, 8
:doc:`data <./data>`, ""
:doc:`c_array <./c_array>`, ""
:doc:`find <./find>`, ""
:doc:`rfind <./rfind>`, ""
:doc:`find_first_of <./find_first_of>`, ""
:doc:`find_last_of <./find_last_of>`, ""
:doc:`find_first_not_of <./find_first_not_of>`, ""
:doc:`find_last_not_of <./find_last_not_of>`, ""
:doc:`substr <./substr>`, ""
:doc:`compare <./compare>`, ""
2013-09-06 14:27:44 +09:00
conversions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2014-08-15 21:27:31 +09:00
.. csv-table::
:header: function
:widths: 4, 8
:doc:`operator std::basic_string <./operator-std-basic_string>`, ""
2013-09-06 14:27:44 +09:00
construct/copy/destroy (for string iterator)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2014-08-15 21:27:31 +09:00
.. csv-table::
:header: function
:widths: 4, 8
:doc:`operator= <./operator-assign-iterator>`, ""
2013-09-06 14:27:44 +09:00
modifiers (for string iterator)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2014-08-15 21:27:31 +09:00
.. csv-table::
:header: function
:widths: 4, 8
:doc:`assign <./assign-iterator>`, ""
2013-09-06 14:27:44 +09:00
string operations (for string iterator)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2014-08-15 21:27:31 +09:00
.. csv-table::
:header: function
:widths: 4, 8
:doc:`find <./find-iterator>`, ""
:doc:`rfind <./rfind-iterator>`, ""
:doc:`find_first_of <./find_first_of-iterator>`, ""
:doc:`find_last_of <./find_last_of-iterator>`, ""
:doc:`find_first_not_of <./find_first_not_of-iterator>`, ""
:doc:`find_last_not_of <./find_last_not_of-iterator>`, ""
:doc:`compare <./compare-iterator>`, ""
2013-09-06 14:27:44 +09:00
Header
========================================
``sprout/string/string.hpp``
Convenience header: ``sprout/string.hpp``
Interface of all
========================================
.. sourcecode:: c++
template <typename T, std::size_t N, typename Traits = sprout::char_traits<T> >
class basic_string {
// types:
typedef Traits traits_type;
typedef typename Traits::char_type value_type;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef value_type& reference;
typedef value_type const& const_reference;
typedef value_type* pointer;
typedef value_type const* const_pointer;
typedef /*implementation-defined*/ iterator;
typedef /*implementation-defined*/ const_iterator;
typedef sprout::reverse_iterator<iterator> reverse_iterator;
typedef sprout::reverse_iterator<const_iterator> const_reverse_iterator;
// constants:
SPROUT_STATIC_CONSTEXPR size_type npos = -1;
SPROUT_STATIC_CONSTEXPR size_type static_size = N;
// construct/copy/destroy:
SPROUT_CONSTEXPR basic_string() = default;
SPROUT_CONSTEXPR basic_string(basic_string const&) = default;
template<std::size_t N2, typename Enable = typename std::enable_if<(N2 < N)>::type>
SPROUT_CONSTEXPR basic_string(basic_string<T, N2, Traits> const& str);
SPROUT_CONSTEXPR basic_string(basic_string const& str, size_type pos, size_type n = npos);
template<std::size_t N2, typename Enable = typename std::enable_if<(N2 < N)>::type>
SPROUT_CONSTEXPR basic_string(basic_string<T, N2, Traits> const& str, size_type pos, size_type n = npos);
template<std::size_t N2, typename Enable = typename std::enable_if<(N2 - 1 <= N)>::type>
SPROUT_CONSTEXPR basic_string(T const(& arr)[N2]);
template<std::size_t N2, typename Enable = typename std::enable_if<(N2 - 1 <= N)>::type>
SPROUT_CONSTEXPR basic_string(T const(& arr)[N2], size_type n);
explicit SPROUT_CONSTEXPR basic_string(value_type const* s);
SPROUT_CONSTEXPR basic_string(value_type const* s, size_type n);
2013-09-09 19:49:37 +09:00
SPROUT_CONSTEXPR basic_string(size_type n, value_type c);
2013-09-06 14:27:44 +09:00
template<typename InputIterator>
SPROUT_CONSTEXPR basic_string(InputIterator first, InputIterator last);
2013-11-04 14:31:03 +09:00
SPROUT_INITIALIZER_LIST_CONSTEXPR basic_string(std::initializer_list<value_type> il);
SPROUT_CXX14_CONSTEXPR basic_string& operator=(basic_string const& rhs);
2013-09-06 14:27:44 +09:00
template<std::size_t N2, typename Enable = typename std::enable_if<(N2 != N)>::type>
2013-11-04 14:31:03 +09:00
SPROUT_CXX14_CONSTEXPR basic_string& operator=(basic_string<T, N2, Traits> const& rhs);
SPROUT_CXX14_CONSTEXPR basic_string& operator=(value_type const* rhs);
SPROUT_CXX14_CONSTEXPR basic_string& operator=(value_type rhs);
2013-09-06 14:27:44 +09:00
// iterators:
2013-11-04 14:31:03 +09:00
SPROUT_CXX14_CONSTEXPR iterator begin() SPROUT_NOEXCEPT;
2013-09-06 14:27:44 +09:00
SPROUT_CONSTEXPR const_iterator begin() const SPROUT_NOEXCEPT;
2013-11-04 14:31:03 +09:00
SPROUT_CXX14_CONSTEXPR iterator end() SPROUT_NOEXCEPT;
2013-09-06 14:27:44 +09:00
SPROUT_CONSTEXPR const_iterator end() const SPROUT_NOEXCEPT;
2013-11-04 14:31:03 +09:00
SPROUT_CXX14_CONSTEXPR reverse_iterator rbegin() SPROUT_NOEXCEPT;
2013-09-06 14:27:44 +09:00
SPROUT_CONSTEXPR const_reverse_iterator rbegin() const SPROUT_NOEXCEPT;
2013-11-04 14:31:03 +09:00
SPROUT_CXX14_CONSTEXPR reverse_iterator rend() SPROUT_NOEXCEPT;
2013-09-06 14:27:44 +09:00
SPROUT_CONSTEXPR const_reverse_iterator rend() const SPROUT_NOEXCEPT;
SPROUT_CONSTEXPR const_iterator cbegin() const SPROUT_NOEXCEPT;
SPROUT_CONSTEXPR const_iterator cend() const SPROUT_NOEXCEPT;
SPROUT_CONSTEXPR const_reverse_iterator crbegin() const SPROUT_NOEXCEPT;
SPROUT_CONSTEXPR const_reverse_iterator crend() const SPROUT_NOEXCEPT;
// capacity:
SPROUT_CONSTEXPR size_type size() const SPROUT_NOEXCEPT;
SPROUT_CONSTEXPR size_type length() const SPROUT_NOEXCEPT;
SPROUT_CONSTEXPR size_type max_size() const SPROUT_NOEXCEPT;
2013-11-04 14:31:03 +09:00
SPROUT_CXX14_CONSTEXPR void resize(size_type n, value_type c);
SPROUT_CXX14_CONSTEXPR void resize(size_type n);
SPROUT_CXX14_CONSTEXPR void clear() SPROUT_NOEXCEPT;
2013-09-06 14:27:44 +09:00
SPROUT_CONSTEXPR bool empty() const SPROUT_NOEXCEPT;
// element access:
2013-11-04 14:31:03 +09:00
SPROUT_CXX14_CONSTEXPR reference operator[](size_type i);
2013-09-06 14:27:44 +09:00
SPROUT_CONSTEXPR const_reference operator[](size_type i) const;
2013-11-04 14:31:03 +09:00
SPROUT_CXX14_CONSTEXPR reference at(size_type i);
2013-09-06 14:27:44 +09:00
SPROUT_CONSTEXPR const_reference at(size_type i) const;
2013-11-04 14:31:03 +09:00
SPROUT_CXX14_CONSTEXPR reference front();
2013-09-06 14:27:44 +09:00
SPROUT_CONSTEXPR const_reference front() const;
2013-11-04 14:31:03 +09:00
SPROUT_CXX14_CONSTEXPR reference back();
2013-09-06 14:27:44 +09:00
SPROUT_CONSTEXPR const_reference back() const;
// modifiers:
template<std::size_t N2>
2013-11-04 14:31:03 +09:00
SPROUT_CXX14_CONSTEXPR basic_string& assign(basic_string<T, N2, Traits> const& str);
2013-09-06 14:27:44 +09:00
template<std::size_t N2>
2013-11-04 14:31:03 +09:00
SPROUT_CXX14_CONSTEXPR basic_string& assign(basic_string<T, N2, Traits> const& str, size_type pos, size_type n);
SPROUT_CXX14_CONSTEXPR basic_string& assign(value_type const* s, size_type n);
SPROUT_CXX14_CONSTEXPR basic_string& assign(value_type const* s);
SPROUT_CXX14_CONSTEXPR basic_string& assign(size_type n, value_type c);
template<typename InputIterator>
2013-11-04 14:31:03 +09:00
SPROUT_CXX14_CONSTEXPR basic_string& assign(InputIterator first, InputIterator last);
SPROUT_CXX14_CONSTEXPR void swap(basic_string& other) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::swap(std::declval<T&>(), std::declval<T&>())));
2013-09-06 14:27:44 +09:00
// string operations:
SPROUT_CONSTEXPR const_pointer c_str() const SPROUT_NOEXCEPT;
2013-11-04 14:31:03 +09:00
SPROUT_CXX14_CONSTEXPR pointer data() SPROUT_NOEXCEPT;
2013-09-06 14:27:44 +09:00
SPROUT_CONSTEXPR const_pointer data() const SPROUT_NOEXCEPT;
2013-11-04 14:31:03 +09:00
SPROUT_CXX14_CONSTEXPR pointer c_array() SPROUT_NOEXCEPT;
2013-09-06 14:27:44 +09:00
SPROUT_CONSTEXPR const_pointer c_array() const SPROUT_NOEXCEPT;
template<std::size_t N2>
SPROUT_CONSTEXPR size_type find(basic_string<T, N2, Traits> const& str, size_type pos = 0) const SPROUT_NOEXCEPT;
SPROUT_CONSTEXPR size_type find(value_type const* s, size_type pos, size_type n) const;
SPROUT_CONSTEXPR size_type find(value_type const* s, size_type pos = 0) const;
SPROUT_CONSTEXPR size_type find(value_type c, size_type pos = 0) const;
template<std::size_t N2>
SPROUT_CONSTEXPR size_type rfind(basic_string<T, N2, Traits> const& str, size_type pos = npos) const SPROUT_NOEXCEPT;
SPROUT_CONSTEXPR size_type rfind(value_type const* s, size_type pos, size_type n) const;
SPROUT_CONSTEXPR size_type rfind(value_type const* s, size_type pos = npos) const;
SPROUT_CONSTEXPR size_type rfind(value_type c, size_type pos = npos) const;
template<std::size_t N2>
SPROUT_CONSTEXPR size_type find_first_of(basic_string<T, N2, Traits> const& str, size_type pos = 0) const SPROUT_NOEXCEPT;
SPROUT_CONSTEXPR size_type find_first_of(value_type const* s, size_type pos, size_type n) const;
SPROUT_CONSTEXPR size_type find_first_of(value_type const* s, size_type pos = 0) const;
SPROUT_CONSTEXPR size_type find_first_of(value_type c, size_type pos = 0) const;
template<std::size_t N2>
SPROUT_CONSTEXPR size_type find_last_of(basic_string<T, N2, Traits> const& str, size_type pos = npos) const SPROUT_NOEXCEPT;
SPROUT_CONSTEXPR size_type find_last_of(value_type const* s, size_type pos, size_type n) const;
SPROUT_CONSTEXPR size_type find_last_of(value_type const* s, size_type pos = npos) const;
SPROUT_CONSTEXPR size_type find_last_of(value_type c, size_type pos = npos) const;
template<std::size_t N2>
SPROUT_CONSTEXPR size_type find_first_not_of(basic_string<T, N2, Traits> const& str, size_type pos = 0) const SPROUT_NOEXCEPT;
SPROUT_CONSTEXPR size_type find_first_not_of(value_type const* s, size_type pos, size_type n) const;
SPROUT_CONSTEXPR size_type find_first_not_of(value_type const* s, size_type pos = 0) const;
SPROUT_CONSTEXPR size_type find_first_not_of(value_type c, size_type pos = 0) const;
template<std::size_t N2>
SPROUT_CONSTEXPR size_type find_last_not_of(basic_string<T, N2, Traits> const& str, size_type pos = npos) const SPROUT_NOEXCEPT;
SPROUT_CONSTEXPR size_type find_last_not_of(value_type const* s, size_type pos, size_type n) const;
SPROUT_CONSTEXPR size_type find_last_not_of(value_type const* s, size_type pos = npos) const;
SPROUT_CONSTEXPR size_type find_last_not_of(value_type c, size_type pos = npos) const;
SPROUT_CONSTEXPR basic_string substr(size_type pos = 0, size_type n = npos) const;
template<std::size_t N2>
SPROUT_CONSTEXPR int compare(basic_string<T, N2, Traits> const& str) const;
SPROUT_CONSTEXPR int compare(value_type const* s) const;
template<std::size_t N2>
SPROUT_CONSTEXPR int compare(size_type pos1, size_type n1, basic_string<T, N2, Traits> const& str) const;
SPROUT_CONSTEXPR int compare(size_type pos1, size_type n1, value_type const* s) const;
template<std::size_t N2>
SPROUT_CONSTEXPR int compare(size_type pos1, size_type n1, basic_string<T, N2, Traits> const& str, size_type pos2, size_type n2) const;
SPROUT_CONSTEXPR int compare(size_type pos1, size_type n1, value_type const* s, size_type n2) const;
// conversions:
template<typename Allocator>
2013-11-04 14:31:03 +09:00
SPROUT_EXPLICIT_CONVERSION SPROUT_NON_CONSTEXPR operator std::basic_string<T, Traits, Allocator>() const;
2013-09-06 14:27:44 +09:00
// construct/copy/destroy (for string iterator):
template<typename StringConstIterator>
2013-11-04 14:31:03 +09:00
SPROUT_CXX14_CONSTEXPR basic_string& operator=(StringConstIterator rhs);
2013-09-06 14:27:44 +09:00
// modifiers (for string iterator):
template<typename StringConstIterator>
2013-11-04 14:31:03 +09:00
SPROUT_CXX14_CONSTEXPR basic_string& assign(StringConstIterator s, size_type n);
2013-09-06 14:27:44 +09:00
template<typename StringConstIterator>
2013-11-04 14:31:03 +09:00
SPROUT_CXX14_CONSTEXPR basic_string& assign(StringConstIterator s);
2013-09-06 14:27:44 +09:00
// string operations (for string iterator):
template<typename StringConstIterator>
SPROUT_CONSTEXPR size_type find(StringConstIterator s, size_type pos, size_type n) const;
template<typename StringConstIterator>
SPROUT_CONSTEXPR size_type find(StringConstIterator s, size_type pos = 0) const;
template<typename StringConstIterator>
SPROUT_CONSTEXPR size_type rfind(StringConstIterator s, size_type pos, size_type n) const;
template<typename StringConstIterator>
SPROUT_CONSTEXPR size_type rfind(StringConstIterator s, size_type pos = npos) const;
template<typename StringConstIterator>
SPROUT_CONSTEXPR size_type find_first_of(StringConstIterator s, size_type pos, size_type n) const;
template<typename StringConstIterator>
SPROUT_CONSTEXPR size_type find_first_of(StringConstIterator s, size_type pos = 0) const;
template<typename StringConstIterator>
SPROUT_CONSTEXPR size_type find_last_of(StringConstIterator s, size_type pos, size_type n) const;
template<typename StringConstIterator>
SPROUT_CONSTEXPR size_type find_last_of(StringConstIterator s, size_type pos = 0) const;
template<typename StringConstIterator>
SPROUT_CONSTEXPR size_type find_first_not_of(StringConstIterator s, size_type pos, size_type n) const;
template<typename StringConstIterator>
SPROUT_CONSTEXPR size_type find_first_not_of(StringConstIterator s, size_type pos = 0) const;
template<typename StringConstIterator>
SPROUT_CONSTEXPR size_type find_last_not_of(StringConstIterator s, size_type pos, size_type n) const;
template<typename StringConstIterator>
SPROUT_CONSTEXPR size_type find_last_not_of(StringConstIterator s, size_type pos = npos) const;
template<typename StringConstIterator>
SPROUT_CONSTEXPR int compare(StringConstIterator s) const;
template<typename StringConstIterator>
SPROUT_CONSTEXPR int compare(size_type pos1, size_type n1, StringConstIterator s) const;
template<typename StringConstIterator>
SPROUT_CONSTEXPR int compare(size_type pos1, size_type n1, StringConstIterator s, size_type n2) const;
};