mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 01:05: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.
|
* Efficient swap for two Optional objects.
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
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)
|
if (a)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,19 +23,6 @@ namespace BlackMisc
|
|||||||
|
|
||||||
namespace Private
|
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.
|
//! \private Dummy that derives from T if T is a class.
|
||||||
template <typename T, bool = std::is_class_v<T>>
|
template <typename T, bool = std::is_class_v<T>>
|
||||||
struct SyntheticDerived : public T {};
|
struct SyntheticDerived : public T {};
|
||||||
|
|||||||
Reference in New Issue
Block a user