War on tabs.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@185865 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant 2013-07-08 21:06:38 +00:00
parent e2735d1df0
commit 171771a9f5
20 changed files with 230 additions and 230 deletions

View File

@ -728,8 +728,8 @@ public:
// arithmetic // arithmetic
_LIBCPP_INLINE_VISIBILITY time_point& operator+=(const duration& __d) {__d_ += __d; return *this;} _LIBCPP_INLINE_VISIBILITY time_point& operator+=(const duration& __d) {__d_ += __d; return *this;}
_LIBCPP_INLINE_VISIBILITY time_point& operator-=(const duration& __d) {__d_ -= __d; return *this;} _LIBCPP_INLINE_VISIBILITY time_point& operator-=(const duration& __d) {__d_ -= __d; return *this;}
// special values // special values

View File

@ -692,10 +692,10 @@ template<class _T1, class _T2 = _T1>
_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY inline
_T1 exchange(_T1& __obj, _T2 && __new_value) _T1 exchange(_T1& __obj, _T2 && __new_value)
{ {
_T1 __old_value = _VSTD::move(__obj); _T1 __old_value = _VSTD::move(__obj);
__obj = _VSTD::forward<_T2>(__new_value); __obj = _VSTD::forward<_T2>(__new_value);
return __old_value; return __old_value;
} }
#endif // _LIBCPP_STD_VER > 11 #endif // _LIBCPP_STD_VER > 11
_LIBCPP_END_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD

View File

@ -18,9 +18,9 @@
namespace { // Private namespace { // Private
struct free_deleter { struct free_deleter {
inline void operator()(char* p) { free(p); } inline void operator()(char* p) { free(p); }
}; };
} }
// Some of these functions aren't standard or if they conform, the name does not. // Some of these functions aren't standard or if they conform, the name does not.

View File

@ -20,7 +20,7 @@
#include "test_iterators.h" #include "test_iterators.h"
#if _LIBCPP_STD_VER > 11 #if _LIBCPP_STD_VER > 11
#define HAS_FOUR_ITERATOR_VERSION #define HAS_FOUR_ITERATOR_VERSION
#endif #endif
int main() int main()

View File

@ -22,15 +22,15 @@
#include "test_iterators.h" #include "test_iterators.h"
#if _LIBCPP_STD_VER > 11 #if _LIBCPP_STD_VER > 11
#define HAS_FOUR_ITERATOR_VERSION #define HAS_FOUR_ITERATOR_VERSION
#endif #endif
int comparison_count = 0; int comparison_count = 0;
template <typename T> template <typename T>
bool counting_equals ( const T &a, const T &b ) { bool counting_equals ( const T &a, const T &b ) {
++comparison_count; ++comparison_count;
return a == b; return a == b;
} }
int main() int main()
{ {

View File

@ -20,7 +20,7 @@
#include "test_iterators.h" #include "test_iterators.h"
#if _LIBCPP_STD_VER > 11 #if _LIBCPP_STD_VER > 11
#define HAS_FOUR_ITERATOR_VERSION #define HAS_FOUR_ITERATOR_VERSION
#endif #endif
int main() int main()

View File

@ -20,6 +20,6 @@ int main()
typedef double T; typedef double T;
typedef std::array<T, 3> C; typedef std::array<T, 3> C;
C c = {1, 2, 3.5}; C c = {1, 2, 3.5};
std::get<3>(c) = 5.5; // Can't get element 3! std::get<3>(c) = 5.5; // Can't get element 3!
} }
} }

View File

@ -19,14 +19,14 @@ static bool gCopyConstructorShouldThow = false;
class CMyClass { class CMyClass {
public: CMyClass(); public: CMyClass();
public: CMyClass(const CMyClass& iOther); public: CMyClass(const CMyClass& iOther);
public: ~CMyClass(); public: ~CMyClass();
private: int fMagicValue; private: int fMagicValue;
private: static int kStartedConstructionMagicValue; private: static int kStartedConstructionMagicValue;
private: static int kFinishedConstructionMagicValue; private: static int kFinishedConstructionMagicValue;
}; };
// Value for fMagicValue when the constructor has started running, but not yet finished // Value for fMagicValue when the constructor has started running, but not yet finished
@ -35,39 +35,39 @@ int CMyClass::kStartedConstructionMagicValue = 0;
int CMyClass::kFinishedConstructionMagicValue = 12345; int CMyClass::kFinishedConstructionMagicValue = 12345;
CMyClass::CMyClass() : CMyClass::CMyClass() :
fMagicValue(kStartedConstructionMagicValue) fMagicValue(kStartedConstructionMagicValue)
{ {
// Signal that the constructor has finished running // Signal that the constructor has finished running
fMagicValue = kFinishedConstructionMagicValue; fMagicValue = kFinishedConstructionMagicValue;
} }
CMyClass::CMyClass(const CMyClass& /*iOther*/) : CMyClass::CMyClass(const CMyClass& /*iOther*/) :
fMagicValue(kStartedConstructionMagicValue) fMagicValue(kStartedConstructionMagicValue)
{ {
// If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
if (gCopyConstructorShouldThow) { if (gCopyConstructorShouldThow) {
throw std::exception(); throw std::exception();
} }
// Signal that the constructor has finished running // Signal that the constructor has finished running
fMagicValue = kFinishedConstructionMagicValue; fMagicValue = kFinishedConstructionMagicValue;
} }
CMyClass::~CMyClass() { CMyClass::~CMyClass() {
// Only instances for which the constructor has finished running should be destructed // Only instances for which the constructor has finished running should be destructed
assert(fMagicValue == kFinishedConstructionMagicValue); assert(fMagicValue == kFinishedConstructionMagicValue);
} }
int main() int main()
{ {
CMyClass instance; CMyClass instance;
std::deque<CMyClass> vec; std::deque<CMyClass> vec;
vec.push_back(instance); vec.push_back(instance);
gCopyConstructorShouldThow = true; gCopyConstructorShouldThow = true;
try { try {
vec.push_back(instance); vec.push_back(instance);
} }
catch (...) { catch (...) {
} }
} }

View File

@ -19,14 +19,14 @@ static bool gCopyConstructorShouldThow = false;
class CMyClass { class CMyClass {
public: CMyClass(); public: CMyClass();
public: CMyClass(const CMyClass& iOther); public: CMyClass(const CMyClass& iOther);
public: ~CMyClass(); public: ~CMyClass();
private: int fMagicValue; private: int fMagicValue;
private: static int kStartedConstructionMagicValue; private: static int kStartedConstructionMagicValue;
private: static int kFinishedConstructionMagicValue; private: static int kFinishedConstructionMagicValue;
}; };
// Value for fMagicValue when the constructor has started running, but not yet finished // Value for fMagicValue when the constructor has started running, but not yet finished
@ -35,39 +35,39 @@ int CMyClass::kStartedConstructionMagicValue = 0;
int CMyClass::kFinishedConstructionMagicValue = 12345; int CMyClass::kFinishedConstructionMagicValue = 12345;
CMyClass::CMyClass() : CMyClass::CMyClass() :
fMagicValue(kStartedConstructionMagicValue) fMagicValue(kStartedConstructionMagicValue)
{ {
// Signal that the constructor has finished running // Signal that the constructor has finished running
fMagicValue = kFinishedConstructionMagicValue; fMagicValue = kFinishedConstructionMagicValue;
} }
CMyClass::CMyClass(const CMyClass& /*iOther*/) : CMyClass::CMyClass(const CMyClass& /*iOther*/) :
fMagicValue(kStartedConstructionMagicValue) fMagicValue(kStartedConstructionMagicValue)
{ {
// If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
if (gCopyConstructorShouldThow) { if (gCopyConstructorShouldThow) {
throw std::exception(); throw std::exception();
} }
// Signal that the constructor has finished running // Signal that the constructor has finished running
fMagicValue = kFinishedConstructionMagicValue; fMagicValue = kFinishedConstructionMagicValue;
} }
CMyClass::~CMyClass() { CMyClass::~CMyClass() {
// Only instances for which the constructor has finished running should be destructed // Only instances for which the constructor has finished running should be destructed
assert(fMagicValue == kFinishedConstructionMagicValue); assert(fMagicValue == kFinishedConstructionMagicValue);
} }
int main() int main()
{ {
CMyClass instance; CMyClass instance;
std::deque<CMyClass> vec; std::deque<CMyClass> vec;
vec.push_front(instance); vec.push_front(instance);
gCopyConstructorShouldThow = true; gCopyConstructorShouldThow = true;
try { try {
vec.push_front(instance); vec.push_front(instance);
} }
catch (...) { catch (...) {
} }
} }

View File

@ -19,14 +19,14 @@ static bool gCopyConstructorShouldThow = false;
class CMyClass { class CMyClass {
public: CMyClass(); public: CMyClass();
public: CMyClass(const CMyClass& iOther); public: CMyClass(const CMyClass& iOther);
public: ~CMyClass(); public: ~CMyClass();
private: int fMagicValue; private: int fMagicValue;
private: static int kStartedConstructionMagicValue; private: static int kStartedConstructionMagicValue;
private: static int kFinishedConstructionMagicValue; private: static int kFinishedConstructionMagicValue;
}; };
// Value for fMagicValue when the constructor has started running, but not yet finished // Value for fMagicValue when the constructor has started running, but not yet finished
@ -35,39 +35,39 @@ int CMyClass::kStartedConstructionMagicValue = 0;
int CMyClass::kFinishedConstructionMagicValue = 12345; int CMyClass::kFinishedConstructionMagicValue = 12345;
CMyClass::CMyClass() : CMyClass::CMyClass() :
fMagicValue(kStartedConstructionMagicValue) fMagicValue(kStartedConstructionMagicValue)
{ {
// Signal that the constructor has finished running // Signal that the constructor has finished running
fMagicValue = kFinishedConstructionMagicValue; fMagicValue = kFinishedConstructionMagicValue;
} }
CMyClass::CMyClass(const CMyClass& /*iOther*/) : CMyClass::CMyClass(const CMyClass& /*iOther*/) :
fMagicValue(kStartedConstructionMagicValue) fMagicValue(kStartedConstructionMagicValue)
{ {
// If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
if (gCopyConstructorShouldThow) { if (gCopyConstructorShouldThow) {
throw std::exception(); throw std::exception();
} }
// Signal that the constructor has finished running // Signal that the constructor has finished running
fMagicValue = kFinishedConstructionMagicValue; fMagicValue = kFinishedConstructionMagicValue;
} }
CMyClass::~CMyClass() { CMyClass::~CMyClass() {
// Only instances for which the constructor has finished running should be destructed // Only instances for which the constructor has finished running should be destructed
assert(fMagicValue == kFinishedConstructionMagicValue); assert(fMagicValue == kFinishedConstructionMagicValue);
} }
int main() int main()
{ {
CMyClass instance; CMyClass instance;
std::forward_list<CMyClass> vec; std::forward_list<CMyClass> vec;
vec.push_front(instance); vec.push_front(instance);
gCopyConstructorShouldThow = true; gCopyConstructorShouldThow = true;
try { try {
vec.push_front(instance); vec.push_front(instance);
} }
catch (...) { catch (...) {
} }
} }

View File

@ -19,14 +19,14 @@ static bool gCopyConstructorShouldThow = false;
class CMyClass { class CMyClass {
public: CMyClass(); public: CMyClass();
public: CMyClass(const CMyClass& iOther); public: CMyClass(const CMyClass& iOther);
public: ~CMyClass(); public: ~CMyClass();
private: int fMagicValue; private: int fMagicValue;
private: static int kStartedConstructionMagicValue; private: static int kStartedConstructionMagicValue;
private: static int kFinishedConstructionMagicValue; private: static int kFinishedConstructionMagicValue;
}; };
// Value for fMagicValue when the constructor has started running, but not yet finished // Value for fMagicValue when the constructor has started running, but not yet finished
@ -35,39 +35,39 @@ int CMyClass::kStartedConstructionMagicValue = 0;
int CMyClass::kFinishedConstructionMagicValue = 12345; int CMyClass::kFinishedConstructionMagicValue = 12345;
CMyClass::CMyClass() : CMyClass::CMyClass() :
fMagicValue(kStartedConstructionMagicValue) fMagicValue(kStartedConstructionMagicValue)
{ {
// Signal that the constructor has finished running // Signal that the constructor has finished running
fMagicValue = kFinishedConstructionMagicValue; fMagicValue = kFinishedConstructionMagicValue;
} }
CMyClass::CMyClass(const CMyClass& /*iOther*/) : CMyClass::CMyClass(const CMyClass& /*iOther*/) :
fMagicValue(kStartedConstructionMagicValue) fMagicValue(kStartedConstructionMagicValue)
{ {
// If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
if (gCopyConstructorShouldThow) { if (gCopyConstructorShouldThow) {
throw std::exception(); throw std::exception();
} }
// Signal that the constructor has finished running // Signal that the constructor has finished running
fMagicValue = kFinishedConstructionMagicValue; fMagicValue = kFinishedConstructionMagicValue;
} }
CMyClass::~CMyClass() { CMyClass::~CMyClass() {
// Only instances for which the constructor has finished running should be destructed // Only instances for which the constructor has finished running should be destructed
assert(fMagicValue == kFinishedConstructionMagicValue); assert(fMagicValue == kFinishedConstructionMagicValue);
} }
int main() int main()
{ {
CMyClass instance; CMyClass instance;
std::list<CMyClass> vec; std::list<CMyClass> vec;
vec.push_back(instance); vec.push_back(instance);
gCopyConstructorShouldThow = true; gCopyConstructorShouldThow = true;
try { try {
vec.push_back(instance); vec.push_back(instance);
} }
catch (...) { catch (...) {
} }
} }

View File

@ -19,14 +19,14 @@ static bool gCopyConstructorShouldThow = false;
class CMyClass { class CMyClass {
public: CMyClass(); public: CMyClass();
public: CMyClass(const CMyClass& iOther); public: CMyClass(const CMyClass& iOther);
public: ~CMyClass(); public: ~CMyClass();
private: int fMagicValue; private: int fMagicValue;
private: static int kStartedConstructionMagicValue; private: static int kStartedConstructionMagicValue;
private: static int kFinishedConstructionMagicValue; private: static int kFinishedConstructionMagicValue;
}; };
// Value for fMagicValue when the constructor has started running, but not yet finished // Value for fMagicValue when the constructor has started running, but not yet finished
@ -35,39 +35,39 @@ int CMyClass::kStartedConstructionMagicValue = 0;
int CMyClass::kFinishedConstructionMagicValue = 12345; int CMyClass::kFinishedConstructionMagicValue = 12345;
CMyClass::CMyClass() : CMyClass::CMyClass() :
fMagicValue(kStartedConstructionMagicValue) fMagicValue(kStartedConstructionMagicValue)
{ {
// Signal that the constructor has finished running // Signal that the constructor has finished running
fMagicValue = kFinishedConstructionMagicValue; fMagicValue = kFinishedConstructionMagicValue;
} }
CMyClass::CMyClass(const CMyClass& /*iOther*/) : CMyClass::CMyClass(const CMyClass& /*iOther*/) :
fMagicValue(kStartedConstructionMagicValue) fMagicValue(kStartedConstructionMagicValue)
{ {
// If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
if (gCopyConstructorShouldThow) { if (gCopyConstructorShouldThow) {
throw std::exception(); throw std::exception();
} }
// Signal that the constructor has finished running // Signal that the constructor has finished running
fMagicValue = kFinishedConstructionMagicValue; fMagicValue = kFinishedConstructionMagicValue;
} }
CMyClass::~CMyClass() { CMyClass::~CMyClass() {
// Only instances for which the constructor has finished running should be destructed // Only instances for which the constructor has finished running should be destructed
assert(fMagicValue == kFinishedConstructionMagicValue); assert(fMagicValue == kFinishedConstructionMagicValue);
} }
int main() int main()
{ {
CMyClass instance; CMyClass instance;
std::list<CMyClass> vec; std::list<CMyClass> vec;
vec.push_front(instance); vec.push_front(instance);
gCopyConstructorShouldThow = true; gCopyConstructorShouldThow = true;
try { try {
vec.push_front(instance); vec.push_front(instance);
} }
catch (...) { catch (...) {
} }
} }

View File

@ -19,14 +19,14 @@ static bool gCopyConstructorShouldThow = false;
class CMyClass { class CMyClass {
public: CMyClass(); public: CMyClass();
public: CMyClass(const CMyClass& iOther); public: CMyClass(const CMyClass& iOther);
public: ~CMyClass(); public: ~CMyClass();
private: int fMagicValue; private: int fMagicValue;
private: static int kStartedConstructionMagicValue; private: static int kStartedConstructionMagicValue;
private: static int kFinishedConstructionMagicValue; private: static int kFinishedConstructionMagicValue;
}; };
// Value for fMagicValue when the constructor has started running, but not yet finished // Value for fMagicValue when the constructor has started running, but not yet finished
@ -35,39 +35,39 @@ int CMyClass::kStartedConstructionMagicValue = 0;
int CMyClass::kFinishedConstructionMagicValue = 12345; int CMyClass::kFinishedConstructionMagicValue = 12345;
CMyClass::CMyClass() : CMyClass::CMyClass() :
fMagicValue(kStartedConstructionMagicValue) fMagicValue(kStartedConstructionMagicValue)
{ {
// Signal that the constructor has finished running // Signal that the constructor has finished running
fMagicValue = kFinishedConstructionMagicValue; fMagicValue = kFinishedConstructionMagicValue;
} }
CMyClass::CMyClass(const CMyClass& /*iOther*/) : CMyClass::CMyClass(const CMyClass& /*iOther*/) :
fMagicValue(kStartedConstructionMagicValue) fMagicValue(kStartedConstructionMagicValue)
{ {
// If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
if (gCopyConstructorShouldThow) { if (gCopyConstructorShouldThow) {
throw std::exception(); throw std::exception();
} }
// Signal that the constructor has finished running // Signal that the constructor has finished running
fMagicValue = kFinishedConstructionMagicValue; fMagicValue = kFinishedConstructionMagicValue;
} }
CMyClass::~CMyClass() { CMyClass::~CMyClass() {
// Only instances for which the constructor has finished running should be destructed // Only instances for which the constructor has finished running should be destructed
assert(fMagicValue == kFinishedConstructionMagicValue); assert(fMagicValue == kFinishedConstructionMagicValue);
} }
int main() int main()
{ {
CMyClass instance; CMyClass instance;
std::vector<CMyClass> vec; std::vector<CMyClass> vec;
vec.push_back(instance); vec.push_back(instance);
gCopyConstructorShouldThow = true; gCopyConstructorShouldThow = true;
try { try {
vec.push_back(instance); vec.push_back(instance);
} }
catch (...) { catch (...) {
} }
} }

View File

@ -22,16 +22,16 @@
int main() int main()
{ {
int bad=-1; int bad=-1;
std::ostringstream os; std::ostringstream os;
os << "aaaabbbb" << static_cast<char>(bad) os << "aaaabbbb" << static_cast<char>(bad)
<< "ccccdddd" << std::endl; << "ccccdddd" << std::endl;
std::string s=os.str(); std::string s=os.str();
std::istringstream is(s); std::istringstream is(s);
const unsigned int ignoreLen=10; const unsigned int ignoreLen=10;
size_t a=is.tellg(); size_t a=is.tellg();
is.ignore(ignoreLen); is.ignore(ignoreLen);
size_t b=is.tellg(); size_t b=is.tellg();
assert((b-a)==ignoreLen); assert((b-a)==ignoreLen);
} }

View File

@ -22,11 +22,11 @@ struct A
struct B struct B
{ {
B() B()
{ {
// http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#475 // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#475
assert(!std::uncaught_exception()); assert(!std::uncaught_exception());
} }
}; };
int main() int main()

View File

@ -290,7 +290,7 @@ inline Iter base(bidirectional_iterator<Iter> i) { return i.base(); }
template <class Iter> template <class Iter>
inline Iter base(random_access_iterator<Iter> i) { return i.base(); } inline Iter base(random_access_iterator<Iter> i) { return i.base(); }
template <class Iter> // everything else template <class Iter> // everything else
inline Iter base(Iter i) { return i; } inline Iter base(Iter i) { return i; }
#endif // ITERATORS_H #endif // ITERATORS_H

View File

@ -18,10 +18,10 @@
#include <functional> #include <functional>
struct X{ struct X{
typedef std::function<void(X&)> callback_type; typedef std::function<void(X&)> callback_type;
virtual ~X() {} virtual ~X() {}
private: private:
callback_type _cb; callback_type _cb;
}; };
int main() int main()

View File

@ -27,8 +27,8 @@ int main()
#endif #endif
#if _LIBCPP_STD_VER > 11 #if _LIBCPP_STD_VER > 11
static_assert ( _5{}() == 5, "" ); static_assert ( _5{}() == 5, "" );
static_assert ( std::true_type{}(), "" ); static_assert ( std::true_type{}(), "" );
#endif #endif
static_assert(std::false_type::value == false, ""); static_assert(std::false_type::value == false, "");

View File

@ -134,8 +134,8 @@ int main()
test_is_not_convertible<char, Array> (); test_is_not_convertible<char, Array> ();
test_is_not_convertible<char, Array&> (); test_is_not_convertible<char, Array&> ();
test_is_convertible<char, char> (); test_is_convertible<char, char> ();
static_assert((!std::is_convertible<char, char&>::value), ""); static_assert((!std::is_convertible<char, char&>::value), "");
static_assert(( std::is_convertible<char, const char&>::value), ""); static_assert(( std::is_convertible<char, const char&>::value), "");
static_assert((!std::is_convertible<const char, char&>::value), ""); static_assert((!std::is_convertible<const char, char&>::value), "");
@ -151,8 +151,8 @@ int main()
test_is_not_convertible<char&, Array> (); test_is_not_convertible<char&, Array> ();
test_is_not_convertible<char&, Array&> (); test_is_not_convertible<char&, Array&> ();
test_is_convertible<char&, char> (); test_is_convertible<char&, char> ();
static_assert(( std::is_convertible<char&, char&>::value), ""); static_assert(( std::is_convertible<char&, char&>::value), "");
static_assert(( std::is_convertible<char&, const char&>::value), ""); static_assert(( std::is_convertible<char&, const char&>::value), "");
static_assert((!std::is_convertible<const char&, char&>::value), ""); static_assert((!std::is_convertible<const char&, char&>::value), "");
@ -168,9 +168,9 @@ int main()
test_is_not_convertible<char*, Array> (); test_is_not_convertible<char*, Array> ();
test_is_not_convertible<char*, Array&> (); test_is_not_convertible<char*, Array&> ();
test_is_not_convertible<char*, char> (); test_is_not_convertible<char*, char> ();
test_is_not_convertible<char*, char&> (); test_is_not_convertible<char*, char&> ();
static_assert(( std::is_convertible<char*, char*>::value), ""); static_assert(( std::is_convertible<char*, char*>::value), "");
static_assert(( std::is_convertible<char*, const char*>::value), ""); static_assert(( std::is_convertible<char*, const char*>::value), "");
static_assert((!std::is_convertible<const char*, char*>::value), ""); static_assert((!std::is_convertible<const char*, char*>::value), "");

View File

@ -18,30 +18,30 @@
int main() int main()
{ {
#if _LIBCPP_STD_VER > 11 #if _LIBCPP_STD_VER > 11
{ {
int v = 12; int v = 12;
assert ( std::exchange ( v, 23 ) == 12 ); assert ( std::exchange ( v, 23 ) == 12 );
assert ( v == 23 ); assert ( v == 23 );
assert ( std::exchange ( v, 67.2 ) == 23 ); assert ( std::exchange ( v, 67.2 ) == 23 );
assert ( v = 67 ); assert ( v = 67 );
} }
{ {
bool b = false; bool b = false;
assert ( !std::exchange ( b, true )); assert ( !std::exchange ( b, true ));
assert ( b ); assert ( b );
} }
{ {
const std::string s1 ( "Hi Mom!" ); const std::string s1 ( "Hi Mom!" );
const std::string s2 ( "Yo Dad!" ); const std::string s2 ( "Yo Dad!" );
std::string s3 = s1; // Mom std::string s3 = s1; // Mom
assert ( std::exchange ( s3, s2 ) == s1 ); assert ( std::exchange ( s3, s2 ) == s1 );
assert ( s3 == s2 ); assert ( s3 == s2 );
assert ( std::exchange ( s3, "Hi Mom!" ) == s2 ); assert ( std::exchange ( s3, "Hi Mom!" ) == s2 );
assert ( s3 == s1 ); assert ( s3 == s1 );
assert ( std::exchange ( s3, "" ) == s1 ); assert ( std::exchange ( s3, "" ) == s1 );
assert ( s3.size () == 0 ); assert ( s3.size () == 0 );
} }
#endif #endif
} }