Use std::is_nothrow_swappable (C++17 feature)

This commit is contained in:
Mat Sutcliffe
2021-04-17 22:58:11 +01:00
parent 76c59e88ea
commit 17d6e86c19
2 changed files with 1 additions and 14 deletions

View File

@@ -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)
{

View File

@@ -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 {};