basedOpinionated utility library |
git clone git://git.dimitrijedobrota.com/based.git |
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING |
commit | 639b106015bc740d6eec37a5316aac64ca28556f |
parent | fa7619b77db3f4393d1b318cad5bf185c71c45e3 |
author | Dimitrije Dobrota < mail@dimitrijedobrota.com > |
date | Wed, 25 Jun 2025 16:58:56 +0200 |
Some more concepts
A | include/based/concept/is_bool_testable.hpp | | | +++++++++++++++++ |
A | include/based/concept/is_destructible.hpp | | | +++++++++++++++++ |
A | include/based/concept/is_referenceable.hpp | | | +++++++++++ |
A | include/based/concept/is_swappable.hpp | | | ++++++++++++++++++++ |
4 files changed, 65 insertions(+), 0 deletions(-)
diff --git a/ include/based/concept/is_bool_testable.hpp b/ include/based/concept/is_bool_testable.hpp
@@ -0,0 +1,17 @@
#pragma once
#include "based/concept/is_convertible.hpp"
#include "based/utility/forward.hpp"
namespace based::trait
{
template<class T>
concept IsBoolTestable = requires(T&& val) {
requires(IsConvertible<T, bool>);
// clang-format off
{ !forward<T>(val) } -> IsConvertible<bool>;
// clang-format on
};
} // namespace based::trait
diff --git a/ include/based/concept/is_destructible.hpp b/ include/based/concept/is_destructible.hpp
@@ -0,0 +1,17 @@
#pragma once
#include <type_traits>
namespace based::trait
{
template<class T>
concept IsDestructible = std::is_destructible_v<T>;
template<class T>
concept IsTriviallyDestructible = std::is_trivially_destructible_v<T>;
template<class T>
concept IsNothrowDestructible = std::is_nothrow_destructible_v<T>;
} // namespace based::trait
diff --git a/ include/based/concept/is_referenceable.hpp b/ include/based/concept/is_referenceable.hpp
@@ -0,0 +1,11 @@
#pragma once
#include "based/concept/is_same.hpp"
namespace based::trait
{
template<class T>
concept IsReferenceable = !IsSame<void, T>;
} // namespace based::trait
diff --git a/ include/based/concept/is_swappable.hpp b/ include/based/concept/is_swappable.hpp
@@ -0,0 +1,20 @@
#pragma once
#include <type_traits>
namespace based::trait
{
template<class T>
concept IsSwappable = std::is_swappable_v<T>;
template<class T, class U>
concept IsSwappableWith = std::is_swappable_with_v<T, U>;
template<class T>
concept IsNothrowSwappable = std::is_nothrow_swappable_v<T>;
template<class T, class U>
concept IsNothrowSwappableWith = std::is_nothrow_swappable_with_v<T, U>;
} // namespace based::trait