- memory[meta header]
- std[meta namespace]
- function template[meta id-type]
- cpp11[meta cpp]
namespace std {
template <class T>
void swap(shared_ptr<T>& a, shared_ptr<T>& b) noexcept;
}2つのshared_ptrオブジェクトを入れ替える。
a.swap(b)
なし
投げない
#include <iostream>
#include <memory>
int main()
{
std::shared_ptr<int> a(new int(3));
std::shared_ptr<int> b(new int(1));
// aとbを入れ替える
std::swap(a, b);
std::cout << *a << std::endl;
std::cout << *b << std::endl;
}- std::swap[color ff0000]
1
3
- C++11
- GCC: 4.3.6
- Clang libc++, C++11 mode: 3.0
- ICC: ?
- Visual C++: 2008 (TR1), 2010, 2012, 2013