Skip to content

Commit 2a22036

Browse files
committed
Formatting, unsupported no-exceptions, directly use std::swap
1 parent baba555 commit 2a22036

File tree

4 files changed

+68
-65
lines changed

4 files changed

+68
-65
lines changed

libcxx/include/__exception/exception_ptr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
8585
exception_ptr& operator=(const exception_ptr&) _NOEXCEPT;
8686
_LIBCPP_HIDE_FROM_ABI exception_ptr& operator=(exception_ptr&& __other) _NOEXCEPT {
8787
exception_ptr __tmp(std::move(__other));
88-
swap(__tmp, *this);
88+
std::swap(__tmp, *this);
8989
return *this;
9090
}
9191
~exception_ptr() _NOEXCEPT;

libcxx/test/std/language.support/support.exception/propagation/exception_ptr_move_assignment.cpp

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
// UNSUPPORTED: no-exceptions
10+
911
// <exception>
1012

1113
// typedef unspecified exception_ptr;
@@ -18,27 +20,26 @@
1820

1921
#include "test_macros.h"
2022

21-
int main(int, char**)
22-
{
23-
std::exception_ptr p = std::make_exception_ptr(42);
24-
std::exception_ptr p2{p};
25-
assert(p2 == p);
26-
// Move assignment
27-
std::exception_ptr p3
28-
p3 = std::move(p2);
29-
assert(p3 == p);
30-
// `p2` was moved from. In libc++ it will be nullptr, but
31-
// this is not guaranteed by the standard.
32-
#if defined(_LIBCPP_VERSION) && !defined(_LIBCPP_ABI_MICROSOFT)
33-
assert(p2 == nullptr);
34-
assert(p2 == nullptr);
35-
#endif
36-
37-
try {
38-
std::rethrow_exception(p3);
39-
} catch (int e) {
40-
assert(e == 42);
41-
}
42-
43-
return 0;
44-
}
23+
int main(int, char**) {
24+
std::exception_ptr p = std::make_exception_ptr(42);
25+
std::exception_ptr p2{p};
26+
assert(p2 == p);
27+
// Under test: the move assignment
28+
std::exception_ptr p3;
29+
p3 = std::move(p2);
30+
assert(p3 == p);
31+
// `p2` was moved from. In libc++ it will be nullptr, but
32+
// this is not guaranteed by the standard.
33+
#if defined(_LIBCPP_VERSION) && !defined(_LIBCPP_ABI_MICROSOFT)
34+
assert(p2 == nullptr);
35+
assert(p2 == nullptr);
36+
#endif
37+
38+
try {
39+
std::rethrow_exception(p3);
40+
} catch (int e) {
41+
assert(e == 42);
42+
}
43+
44+
return 0;
45+
}

libcxx/test/std/language.support/support.exception/propagation/exception_ptr_move_ctr.cpp

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
// UNSUPPORTED: no-exceptions
10+
911
// <exception>
1012

1113
// typedef unspecified exception_ptr;
@@ -18,25 +20,24 @@
1820

1921
#include "test_macros.h"
2022

21-
int main(int, char**)
22-
{
23-
std::exception_ptr p = std::make_exception_ptr(42);
24-
std::exception_ptr p2{p};
25-
assert(p2 == p);
26-
// Move constructor
27-
std::exception_ptr p3{std::move(p2)};
28-
assert(p3 == p);
29-
// `p2` was moved from. In libc++ it will be nullptr, but
30-
// this is not guaranteed by the standard.
31-
#if defined(_LIBCPP_VERSION) && !defined(_LIBCPP_ABI_MICROSOFT)
32-
assert(p2 == nullptr);
33-
#endif
34-
35-
try {
36-
std::rethrow_exception(p3);
37-
} catch (int e) {
38-
assert(e == 42);
39-
}
40-
41-
return 0;
42-
}
23+
int main(int, char**) {
24+
std::exception_ptr p = std::make_exception_ptr(42);
25+
std::exception_ptr p2{p};
26+
assert(p2 == p);
27+
// Under test: The move constructor
28+
std::exception_ptr p3{std::move(p2)};
29+
assert(p3 == p);
30+
// `p2` was moved from. In libc++ it will be nullptr, but
31+
// this is not guaranteed by the standard.
32+
#if defined(_LIBCPP_VERSION) && !defined(_LIBCPP_ABI_MICROSOFT)
33+
assert(p2 == nullptr);
34+
#endif
35+
36+
try {
37+
std::rethrow_exception(p3);
38+
} catch (int e) {
39+
assert(e == 42);
40+
}
41+
42+
return 0;
43+
}

libcxx/test/std/language.support/support.exception/propagation/exception_ptr_swap.cpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
// UNSUPPORTED: no-exceptions
10+
911
// <exception>
1012

1113
// typedef unspecified exception_ptr;
@@ -18,22 +20,21 @@
1820

1921
#include "test_macros.h"
2022

21-
int main(int, char**)
22-
{
23-
std::exception_ptr p21 = std::make_exception_ptr(42);
24-
std::exception_ptr p42 = std::make_exception_ptr(21);
25-
std::swap(p42, p21);
26-
27-
try {
28-
std::rethrow_exception(p21);
29-
} catch (int e) {
30-
assert(e == 21);
31-
}
32-
try {
33-
std::rethrow_exception(p42);
34-
} catch (int e) {
35-
assert(e == 42);
36-
}
37-
38-
return 0;
23+
int main(int, char**) {
24+
std::exception_ptr p21 = std::make_exception_ptr(42);
25+
std::exception_ptr p42 = std::make_exception_ptr(21);
26+
std::swap(p42, p21);
27+
28+
try {
29+
std::rethrow_exception(p21);
30+
} catch (int e) {
31+
assert(e == 21);
32+
}
33+
try {
34+
std::rethrow_exception(p42);
35+
} catch (int e) {
36+
assert(e == 42);
37+
}
38+
39+
return 0;
3940
}

0 commit comments

Comments
 (0)