Difference between revisions of "cpp/algorithm/swap"
From cppreference.com
Line 2: | Line 2: | ||
{{cpp/algorithm/sidebar}} | {{cpp/algorithm/sidebar}} | ||
{{ddcl list begin}} | {{ddcl list begin}} | ||
− | {{ddcl list header | algorithm | notes={{mark pre c++11 version}} | + | {{ddcl list header | algorithm | utility | notes={{mark pre c++11 version}}<br>{{mark c++11 version}}}} |
− | + | ||
{{ddcl list item | num=1 | | {{ddcl list item | num=1 | | ||
template< class T > | template< class T > |
Revision as of 12:28, 23 August 2011
Template:cpp/algorithm/sidebar Template:ddcl list begin <tr class="t-dsc-header">
<td> </td><td></td>
<td></td></tr> <tr class="t-dcl ">
<td >template< class T >
void swap( T& a, T& b );
</td>
void swap( T& a, T& b );
<td > (1) </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl ">
<td >template< class T, size_t N >
void swap( T (&a)[N], T (&b)[N]);
</td>
void swap( T (&a)[N], T (&b)[N]);
<td > (2) </td> <td > Template:mark c++11 feature </td> </tr> Template:ddcl list end
Exchanges the given values.
1) Swaps the values a
and b
.
2) Swaps the arrays a
and b
. In effect calls Template:cpp.
Contents |
Parameters
a, b | - | the values to be swapped |
Return value
Exceptions
1)noexcept specification:
2) noexcept(noexcept(
std::is_nothrow_move_constructible<Assignable>::value &&
std::is_nothrow_move_assignable<Assignable>::value
noexcept specification:
noexcept(noexcept(swap(*a, *b)))