diff --git a/include/ktl/allocators/fallback.h b/include/ktl/allocators/fallback.h
index c99ab12..181af7b 100644
--- a/include/ktl/allocators/fallback.h
+++ b/include/ktl/allocators/fallback.h
@@ -85,13 +85,13 @@ namespace ktl
fallback& operator=(fallback&&) = default;
bool operator==(const fallback& rhs) const
- noexcept(noexcept(m_Primary == rhs.m_Primary) && noexcept(m_Fallback == rhs.m_Fallback))
+ noexcept(detail::has_nothrow_equal_v
&& detail::has_nothrow_equal_v)
{
return m_Primary == rhs.m_Primary && m_Fallback == rhs.m_Fallback;
}
bool operator!=(const fallback& rhs) const
- noexcept(noexcept(m_Primary != rhs.m_Primary) && noexcept(m_Fallback != rhs.m_Fallback))
+ noexcept(detail::has_nothrow_not_equal_v&& detail::has_nothrow_not_equal_v)
{
return m_Primary != rhs.m_Primary || m_Fallback != rhs.m_Fallback;
}
diff --git a/include/ktl/allocators/freelist.h b/include/ktl/allocators/freelist.h
index 01d1be6..c7479c9 100644
--- a/include/ktl/allocators/freelist.h
+++ b/include/ktl/allocators/freelist.h
@@ -91,13 +91,13 @@ namespace ktl
}
bool operator==(const freelist& rhs) const
- noexcept(noexcept(m_Alloc == rhs.m_Alloc))
+ noexcept(detail::has_nothrow_equal_v)
{
return m_Alloc == rhs.m_Alloc && m_Free == rhs.m_Free;
}
bool operator!=(const freelist& rhs) const
- noexcept(noexcept(m_Alloc != rhs.m_Alloc))
+ noexcept(detail::has_nothrow_not_equal_v)
{
return m_Alloc != rhs.m_Alloc || m_Free != rhs.m_Free;
}
diff --git a/include/ktl/allocators/overflow.h b/include/ktl/allocators/overflow.h
index 05d63fd..96ab73d 100644
--- a/include/ktl/allocators/overflow.h
+++ b/include/ktl/allocators/overflow.h
@@ -82,13 +82,13 @@ namespace ktl
overflow& operator=(overflow&&) = default;
bool operator==(const overflow& rhs) const
- noexcept(noexcept(m_Alloc == rhs.m_Alloc))
+ noexcept(detail::has_nothrow_equal_v)
{
return m_Alloc == rhs.m_Alloc;
}
bool operator!=(const overflow& rhs) const
- noexcept(noexcept(m_Alloc != rhs.m_Alloc))
+ noexcept(detail::has_nothrow_not_equal_v)
{
return m_Alloc != rhs.m_Alloc;
}
diff --git a/include/ktl/allocators/segragator.h b/include/ktl/allocators/segragator.h
index b814740..82c124c 100644
--- a/include/ktl/allocators/segragator.h
+++ b/include/ktl/allocators/segragator.h
@@ -82,13 +82,13 @@ namespace ktl
segragator& operator=(segragator&&) = default;
bool operator==(const segragator& rhs) const
- noexcept(noexcept(m_Primary == rhs.m_Primary) && noexcept(m_Fallback == rhs.m_Fallback))
+ noexcept(detail::has_nothrow_equal_v && detail::has_nothrow_equal_v)
{
return m_Primary == rhs.m_Primary && m_Fallback == rhs.m_Fallback;
}
bool operator!=(const segragator& rhs) const
- noexcept(noexcept(m_Primary != rhs.m_Primary) && noexcept(m_Fallback != rhs.m_Fallback))
+ noexcept(detail::has_nothrow_not_equal_v&& detail::has_nothrow_not_equal_v)
{
return m_Primary != rhs.m_Primary || m_Fallback != rhs.m_Fallback;
}
diff --git a/include/ktl/allocators/shared.h b/include/ktl/allocators/shared.h
index cd6a9d0..f27b574 100644
--- a/include/ktl/allocators/shared.h
+++ b/include/ktl/allocators/shared.h
@@ -91,13 +91,13 @@ namespace ktl
}
bool operator==(const shared& rhs) const
- noexcept(noexcept(m_Block->Allocator == rhs.m_Block->Allocator))
+ noexcept(detail::has_nothrow_equal_v)
{
return m_Block == rhs.m_Block && m_Block->Allocator == rhs.m_Block->Allocator;
}
bool operator!=(const shared& rhs) const
- noexcept(noexcept(m_Block->Allocator != rhs.m_Block->Allocator))
+ noexcept(detail::has_nothrow_not_equal_v)
{
return m_Block != rhs.m_Block || m_Block->Allocator != rhs.m_Block->Allocator;
}
diff --git a/include/ktl/allocators/threaded.h b/include/ktl/allocators/threaded.h
index 6cb5f50..88290f0 100644
--- a/include/ktl/allocators/threaded.h
+++ b/include/ktl/allocators/threaded.h
@@ -95,13 +95,13 @@ namespace ktl
}
bool operator==(const threaded& rhs) const
- noexcept(noexcept(m_Block->Allocator == rhs.m_Block->Allocator))
+ noexcept(detail::has_nothrow_equal_v)
{
return m_Block == rhs.m_Block && m_Block->Allocator == rhs.m_Block->Allocator;
}
bool operator!=(const threaded& rhs) const
- noexcept(noexcept(m_Block->Allocator != rhs.m_Block->Allocator))
+ noexcept(detail::has_nothrow_not_equal_v)
{
return m_Block != rhs.m_Block || m_Block->Allocator != rhs.m_Block->Allocator;
}
diff --git a/include/ktl/allocators/type_allocator.h b/include/ktl/allocators/type_allocator.h
index 0fab362..a795e8d 100644
--- a/include/ktl/allocators/type_allocator.h
+++ b/include/ktl/allocators/type_allocator.h
@@ -177,14 +177,14 @@ namespace ktl
template
bool operator==(const type_allocator& lhs, const type_allocator& rhs)
- noexcept(noexcept(lhs.get_allocator() == rhs.get_allocator()))
+ noexcept(detail::has_nothrow_equal_v)
{
return lhs.get_allocator() == rhs.get_allocator();
}
template
bool operator!=(const type_allocator& lhs, const type_allocator& rhs)
- noexcept(noexcept(lhs.get_allocator() != rhs.get_allocator()))
+ noexcept(detail::has_nothrow_not_equal_v)
{
return lhs.get_allocator() != rhs.get_allocator();
}
diff --git a/include/ktl/utility/meta.h b/include/ktl/utility/meta.h
index 4027154..3374fe8 100644
--- a/include/ktl/utility/meta.h
+++ b/include/ktl/utility/meta.h
@@ -80,6 +80,14 @@ namespace ktl::detail
template
constexpr bool has_nothrow_deallocate_v = noexcept(std::declval().deallocate(std::declval(), std::declval()));
+ // has T& == T& noexcept
+ template
+ constexpr bool has_nothrow_equal_v = noexcept(std::declval() == std::declval());
+
+ // has T& == T& noexcept
+ template
+ constexpr bool has_nothrow_not_equal_v = noexcept(std::declval() == std::declval());
+
// has construct(T*, Args&&...) noexcept
template
struct has_nothrow_construct : std::false_type {};