1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00
Sprout/source/libs/string/basic_string/substr.rst

46 lines
1.1 KiB
ReStructuredText
Raw Normal View History

2013-09-08 13:18:51 +00:00
.. _sprout-string-basic_string-substr:
2014-08-15 12:27:31 +00:00
2013-09-08 13:18:51 +00:00
###############################################################################
substr
###############################################################################
Interface
========================================
.. sourcecode:: c++
SPROUT_CONSTEXPR basic_string substr(size_type pos = 0, size_type n = npos) const;
Requires
========================================
| ``pos <= size()``.
Returns
========================================
2013-09-09 10:49:37 +00:00
| ``basic_string(data() + pos, rlen)`` where rlen is the smaller of n and ``size() - pos``.
2013-09-08 13:18:51 +00:00
Throws
========================================
| std::out_of_range if ``pos > size()``.
Examples
========================================
.. sourcecode:: c++
#include <sprout/string.hpp>
#include <sprout/assert.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto x = string<8>("homuhomu");
SPROUT_STATIC_CONSTEXPR auto y = x.substr(4, 4);
SPROUT_ASSERT_MASG(y == "homu", "y is substring of x.");
Header
========================================
| ``sprout/string/string.hpp``
| Convenience header: ``sprout/string.hpp``