1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
20 #if _LIBCPP_STD_VER > 11
23 assert ( std::exchange ( v, 23 ) == 12 );
25 assert ( std::exchange ( v, 67.2 ) == 23 );
28 assert ((std::exchange<int, float> ( v, {} )) == 67 );
35 assert ( !std::exchange ( b, true ));
40 const std::string s1 ( "Hi Mom!" );
41 const std::string s2 ( "Yo Dad!" );
42 std::string s3 = s1; // Mom
43 assert ( std::exchange ( s3, s2 ) == s1 );
45 assert ( std::exchange ( s3, "Hi Mom!" ) == s2 );
49 assert ( std::exchange ( s3, {} ) == s2 );
50 assert ( s3.size () == 0 );
53 assert ( std::exchange ( s3, "" ) == s2 );
54 assert ( s3.size () == 0 );