Fix pair::swap(const pair&)
and tuple::swap(const tuple&)
errors with __declspec(dllexport)
#3045
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3013, a high-priority customer-reported bug (see DevCom-10109884).
Normally, member functions of class templates are instantiated "on demand". (I like to remember this rule by thinking of
list<T>
, which does not requireT
to be less-than comparable untillist<T>::sort()
is called.) However, if a user derives from a Standard Library class (which we don't encourage, but which is widely done) and then dllexports their derived class, that attempts to instantiate all member functions (that are not templated themselves).By adding member functions (as required by the Standard) that won't compile when force-instantiated like this, #2687 regressed this scenario. The fix is simple (and something we've used elsewhere): add
template <int = 0>
to make instantiation truly on-demand. Conveniently, we already have a test we can expand.(Note: I explored using
requires
to fix this, but that's more verbose and ran into other compiler errors.)