1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// UNSUPPORTED: c++03, c++11, c++14, c++17
10// UNSUPPORTED: no-localization
11// UNSUPPORTED: libcpp-has-no-experimental-syncstream
12
13// <syncstream>
14
15// template<class charT, class traits, class Allocator>
16// void swap(basic_syncbuf<charT, traits, Allocator>&,
17// basic_syncbuf<charT, traits, Allocator>&);
18
19#include <syncstream>
20#include <cassert>
21
22#include "test_macros.h"
23
24template <class CharT>
25void test() {
26 std::basic_syncbuf<CharT> base1;
27 std::basic_syncbuf<CharT> base2;
28 std::basic_syncbuf<CharT> buff1(&base1);
29 std::basic_syncbuf<CharT> buff2(&base2);
30 std::swap(buff1, buff2);
31
32 assert(buff1.get_wrapped() == &base2);
33 assert(buff2.get_wrapped() == &base1);
34}
35
36int main(int, char**) {
37 test<char>();
38#ifndef TEST_HAS_NO_WIDE_CHARACTERS
39 test<wchar_t>();
40#endif
41
42 return 0;
43}
44

source code of libcxx/test/std/input.output/syncstream/syncbuf/syncstream.syncbuf.special/swap.pass.cpp