boostorg / core

Boost Core Utilities
133 stars 83 forks source link

Use `boost::core::invoke_swap` with a `const T&` #155

Open Ukilele opened 1 year ago

Ukilele commented 1 year ago

Hi, this is rather an inquiry than an actual issue. boost::core::invoke_swap only participates in overload resolution, when the type it gets called with is not const qualified (invoke_swap.hpp#L81). C++23 standardized std::ranges::zip_view. As part of the proposal, std::pair and std::tuple got const-qualified overloads of their swap-functions (the rationale can be found here). Should this change be somehow reflected in boost::core::invoke_swap?

Lastique commented 1 year ago

If swapping const values is now allowed, this would probably mean we need to drop the is_const check here. But my understanding is that the support for swapping consts is more of an exception for a given type (pairs and tuples for now) rather than a rule, so I'm not sure that simply dropping is_const is the right way.