Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/algorithm/swap"

From cppreference.com
< cpp‎ | algorithm
m (Text replace - "{{dcl spec" to "{{dcl small")
m (fstream template)
Line 72: Line 72:
 
{{dcl list tfun | cpp/io/basic_stringstream/swap2 | title=std::swap{{dcl small|(std::basic_stringstream)}} | specializes the {{cpp/ltf|cpp/algorithm/swap}} algorithm| notes={{mark c++11}}}}
 
{{dcl list tfun | cpp/io/basic_stringstream/swap2 | title=std::swap{{dcl small|(std::basic_stringstream)}} | specializes the {{cpp/ltf|cpp/algorithm/swap}} algorithm| notes={{mark c++11}}}}
 
{{dcl list tfun | cpp/io/basic_filebuf/swap2 | title=std::swap{{dcl small|(std::basic_filebuf)}} | specializes the {{cpp/ltf|cpp/algorithm/swap}} algorithm| notes={{mark c++11}}}}
 
{{dcl list tfun | cpp/io/basic_filebuf/swap2 | title=std::swap{{dcl small|(std::basic_filebuf)}} | specializes the {{cpp/ltf|cpp/algorithm/swap}} algorithm| notes={{mark c++11}}}}
{{dcl list tfun | cpp/io/basic_ifstream/swap2 | title=std::swap{{dcl small|(std::basic_ifstream)}} | specializes the {{cpp/ltf|cpp/algorithm/swap}} algorithm| notes={{mark c++11}}}}
+
{{dcl list template | cpp/io/basic_fstream/dcl list swap2 | basic_ifstream}}
{{dcl list tfun | cpp/io/basic_ofstream/swap2 | title=std::swap{{dcl small|(std::basic_ofstream)}} | specializes the {{cpp/ltf|cpp/algorithm/swap}} algorithm| notes={{mark c++11}}}}
+
{{dcl list template | cpp/io/basic_fstream/dcl list swap2 | basic_ofstream}}
{{dcl list tfun | cpp/io/basic_fstream/swap2 | title=std::swap{{dcl small|(std::basic_fstream)}} | specializes the {{cpp/ltf|cpp/algorithm/swap}} algorithm| notes={{mark c++11}}}}
+
{{dcl list template | cpp/io/basic_fstream/dcl list swap2 | basic_fstream}}
 
{{dcl list tfun | cpp/regex/basic_regex/swap2 | title=std::swap{{dcl small|(std::basic_regex)}} | specializes the {{cpp/ltf|cpp/algorithm/swap}} algorithm| notes={{mark c++11}}}}
 
{{dcl list tfun | cpp/regex/basic_regex/swap2 | title=std::swap{{dcl small|(std::basic_regex)}} | specializes the {{cpp/ltf|cpp/algorithm/swap}} algorithm| notes={{mark c++11}}}}
 
{{dcl list tfun | cpp/regex/match_results/swap2 | title=std::swap{{dcl small|(std::match_results)}} | specializes the {{cpp/ltf|cpp/algorithm/swap}} algorithm| notes={{mark c++11}}}}
 
{{dcl list tfun | cpp/regex/match_results/swap2 | title=std::swap{{dcl small|(std::match_results)}} | specializes the {{cpp/ltf|cpp/algorithm/swap}} algorithm| notes={{mark c++11}}}}

Revision as of 19:43, 14 December 2011

Template:cpp/algorithm/sidebar Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <algorithm>
Defined in header <utility>
</td>

<td></td>

<td>
Template:mark pre c++11 version
Template:mark c++11 version
</td>

</tr> <tr class="t-dcl ">

<td >
template< class T >
void swap( T& a, T& b );
</td>

<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>

<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

(none)

Exceptions

1)
noexcept specification:  
noexcept(noexcept(

    std::is_nothrow_move_constructible<T>::value &&
    std::is_nothrow_move_assignable<T>::value

))
2)
noexcept specification:  
noexcept(noexcept(swap(*a, *b)))

Complexity

Constant

Specializations

Custom specializations of the Template:cpp algorithm are allowed. The following specializations are already provided by the standard library:

Template:cpp/memory/shared ptr/dcl list swap2Template:cpp/memory/weak ptr/dcl list swap2Template:cpp/memory/unique ptr/dcl list swap2Template:cpp/string/basic string/dcl list swap2Template:cpp/container/dcl list swap2Template:cpp/container/dcl list swap2Template:cpp/container/dcl list swap2Template:cpp/container/dcl list swap2Template:cpp/container/dcl list swap2Template:cpp/container/dcl list swap2Template:cpp/container/dcl list swap2Template:cpp/container/dcl list swap2Template:cpp/container/dcl list swap2Template:cpp/container/dcl list swap2Template:cpp/container/dcl list swap2Template:cpp/container/dcl list swap2Template:cpp/container/dcl list swap2Template:cpp/container/dcl list swap2Template:cpp/container/dcl list swap2Template:cpp/container/dcl list swap2Template:cpp/io/basic fstream/dcl list swap2Template:cpp/io/basic fstream/dcl list swap2Template:cpp/io/basic fstream/dcl list swap2
specializes the std::swap algorithm
(function template) [edit]
specializes the std::swap algorithm
(function template) [edit]
specializes the std::swap algorithm
(function template) [edit]
specializes the Template:cpp/ltf algorithm
(function template)
specializes the Template:cpp/ltf algorithm
(function template)
specializes the Template:cpp/ltf algorithm
(function template)
specializes the Template:cpp/ltf algorithm
(function template)
specializes the Template:cpp/ltf algorithm
(function template)
specializes the Template:cpp/ltf algorithm
(function template)
specializes the Template:cpp/ltf algorithm
(function template)
specializes the Template:cpp/ltf algorithm
(function template)
({{{1}}})
specializes the std::swap algorithm
(function) [edit]
specializes the Template:cpp/ltf algorithm
(function template)
specializes the Template:cpp/ltf algorithm
(function template)
specializes the Template:cpp/ltf algorithm
(function template)

Example

Template:example cpp

See also

Template:cpp/algorithm/dcl list iter swapTemplate:cpp/algorithm/dcl list swap ranges