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/swap.rst
Bolero-MURAKAMI 88ee58bcf4 fix Issue #49
2013-09-13 17:22:10 +09:00

47 lines
1.2 KiB
ReStructuredText

.. _sprout-string-basic_string-swap:
###############################################################################
swap
###############################################################################
Interface
========================================
.. sourcecode:: c++
void swap(basic_string& s) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::swap(std::declval<T&>(), std::declval<T&>())));
Postcondition
========================================
| ``*this`` contains the same sequence of characters that was in s, s contains the same sequence of characters that was in ``*this``.
Throws
========================================
| Nothing unless one of the element-wise swap calls throws an exception.
Examples
========================================
.. sourcecode:: c++
#include <sprout/string.hpp>
#include <sprout/assert.hpp>
using namespace sprout;
auto x = string<8>("homuhomu");
auto y = string<8>("madocchi");
int main() {
swap(x, y);
SPROUT_ASSERT_MSG(x == "madocchi" && y == "homuhomu", "each element are swapped.");
}
Complexity
========================================
| linear.
Header
========================================
| ``sprout/string/string.hpp``
| Convenience header: ``sprout/string.hpp``