mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
Use std::is_nothrow_swappable (C++17 feature)
This commit is contained in:
@@ -121,7 +121,7 @@ namespace BlackMisc
|
||||
* Efficient swap for two Optional objects.
|
||||
*/
|
||||
template <typename T>
|
||||
void swap(Optional<T> &a, Optional<T> &b) noexcept(Private::is_nothrow_swappable<T, T>::value)
|
||||
void swap(Optional<T> &a, Optional<T> &b) noexcept(std::is_nothrow_swappable_v<T>)
|
||||
{
|
||||
if (a)
|
||||
{
|
||||
|
||||
@@ -23,19 +23,6 @@ namespace BlackMisc
|
||||
|
||||
namespace Private
|
||||
{
|
||||
//! \private Own implementation of C++17 std::is_nothrow_swappable.
|
||||
template <typename T, typename U>
|
||||
struct is_nothrow_swappable
|
||||
{
|
||||
static constexpr bool impl()
|
||||
{
|
||||
using std::swap;
|
||||
return noexcept(swap(std::declval<T>(), std::declval<U>()))
|
||||
&& noexcept(swap(std::declval<U>(), std::declval<T>()));
|
||||
}
|
||||
static constexpr bool value = impl();
|
||||
};
|
||||
|
||||
//! \private Dummy that derives from T if T is a class.
|
||||
template <typename T, bool = std::is_class_v<T>>
|
||||
struct SyntheticDerived : public T {};
|
||||
|
||||
Reference in New Issue
Block a user