名前空間
変種
操作

std::swap(std::basic_string)

提供: cppreference.com
< cpp‎ | string‎ | basic string
2020年2月18日 (火) 01:24時点におけるFruderica (トーク | 投稿記録)による版

(差分) ←前の版 | 最新版 (差分) | 次の版→ (差分)
 
 
 
std::basic_string
 
ヘッダ <string> で定義
template< class CharT, class Traits, class Alloc >

void swap( std::basic_string<CharT, Traits, Alloc> &lhs,

           std::basic_string<CharT, Traits, Alloc> &rhs );
(C++17未満)
template< class CharT, class Traits, class Alloc >

void swap( std::basic_string<CharT, Traits, Alloc> &lhs,

           std::basic_string<CharT, Traits, Alloc> &rhs ) noexcept(/* see below */);
(C++17以上)
(C++20未満)
template< class CharT, class Traits, class Alloc >

constexpr void
    swap( std::basic_string<CharT, Traits, Alloc> &lhs,

          std::basic_string<CharT, Traits, Alloc> &rhs ) noexcept(/* see below */);
(C++20以上)

std::swap アルゴリズムを std::basic_string に対して特殊化します。 lhsrhs の内容を入れ替えます。 lhs.swap(rhs) と同等です。

目次

[編集] 引数

lhs, rhs - 内容を入れ替える文字列

[編集] 戻り値

(なし)

[編集] 計算量

一定。

例外

noexcept 指定:  
noexcept(noexcept(lhs.swap(rhs)))
(C++17以上)

[編集] 関連項目

内容を入れ替えます
(パブリックメンバ関数) [edit]