Skip to content

Commit

Permalink
Fix pair::swap(const pair&) and tuple::swap(const tuple&) errors …
Browse files Browse the repository at this point in the history
…with `__declspec(dllexport)` (#3045)
  • Loading branch information
StephanTLavavej authored Aug 22, 2022
1 parent 2a1b881 commit febb643
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions stl/inc/tuple
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ public:
}

#if _HAS_CXX23
template <int = 0> // see GH-3013
constexpr void swap(const tuple& _Right) const
noexcept(conjunction_v<is_nothrow_swappable<const _This>, is_nothrow_swappable<const _Rest>...>) {
_Swap_adl(_Myfirst._Val, _Right._Myfirst._Val);
Expand Down
1 change: 1 addition & 0 deletions stl/inc/utility
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ struct pair { // store a pair of values
}

#if _HAS_CXX23
template <int = 0> // see GH-3013
constexpr void swap(const pair& _Right) const
noexcept(is_nothrow_swappable_v<const _Ty1>&& is_nothrow_swappable_v<const _Ty2>) {
if (this != _STD addressof(_Right)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if _HAS_CXX20
Expand Down Expand Up @@ -50,3 +52,7 @@ struct __declspec(dllexport) ExportedStack : stack<int> {};
struct __declspec(dllexport) ExportedSpan : span<int> {};
struct __declspec(dllexport) ExportedSpanThree : span<int, 3> {};
#endif // _HAS_CXX20

// Test GH-3013 "<utility>: pair::swap(const pair&) interacts badly with __declspec(dllexport)"
struct __declspec(dllexport) ExportedPair : pair<int, int> {};
struct __declspec(dllexport) ExportedTuple : tuple<int, int, int> {};

0 comments on commit febb643

Please sign in to comment.