Skip to content

Commit febb643

Browse files
Fix pair::swap(const pair&) and tuple::swap(const tuple&) errors with __declspec(dllexport) (#3045)
1 parent 2a1b881 commit febb643

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

stl/inc/tuple

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ public:
582582
}
583583

584584
#if _HAS_CXX23
585+
template <int = 0> // see GH-3013
585586
constexpr void swap(const tuple& _Right) const
586587
noexcept(conjunction_v<is_nothrow_swappable<const _This>, is_nothrow_swappable<const _Rest>...>) {
587588
_Swap_adl(_Myfirst._Val, _Right._Myfirst._Val);

stl/inc/utility

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ struct pair { // store a pair of values
329329
}
330330

331331
#if _HAS_CXX23
332+
template <int = 0> // see GH-3013
332333
constexpr void swap(const pair& _Right) const
333334
noexcept(is_nothrow_swappable_v<const _Ty1>&& is_nothrow_swappable_v<const _Ty2>) {
334335
if (this != _STD addressof(_Right)) {

tests/std/tests/GH_001638_dllexport_derived_classes/test.compile.pass.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
#include <queue>
1010
#include <set>
1111
#include <stack>
12+
#include <tuple>
1213
#include <unordered_map>
1314
#include <unordered_set>
15+
#include <utility>
1416
#include <vector>
1517

1618
#if _HAS_CXX20
@@ -50,3 +52,7 @@ struct __declspec(dllexport) ExportedStack : stack<int> {};
5052
struct __declspec(dllexport) ExportedSpan : span<int> {};
5153
struct __declspec(dllexport) ExportedSpanThree : span<int, 3> {};
5254
#endif // _HAS_CXX20
55+
56+
// Test GH-3013 "<utility>: pair::swap(const pair&) interacts badly with __declspec(dllexport)"
57+
struct __declspec(dllexport) ExportedPair : pair<int, int> {};
58+
struct __declspec(dllexport) ExportedTuple : tuple<int, int, int> {};

0 commit comments

Comments
 (0)