Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/internal
diff options
context:
space:
mode:
authorMartin Hořeňovský2022-11-20 15:29:12 +0100
committerMartin Hořeňovský2022-11-20 17:03:29 +0100
commitae1644e7e92b09055af18c4a2d5bc9a027eb16a1 (patch)
treef662070ac56334a3d4206ca772d93a17674231aa /src/catch2/internal
parent65cc7fd2ae39a7a543767f661b096d7d521ee4f0 (diff)
downloadcatch3-ae1644e7e92b09055af18c4a2d5bc9a027eb16a1.tar.gz
Add logical trait polyfills
Diffstat (limited to 'src/catch2/internal')
-rw-r--r--src/catch2/internal/catch_logical_traits.hpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/catch2/internal/catch_logical_traits.hpp b/src/catch2/internal/catch_logical_traits.hpp
new file mode 100644
index 00000000..bd875659
--- /dev/null
+++ b/src/catch2/internal/catch_logical_traits.hpp
@@ -0,0 +1,44 @@
+
+// Copyright Catch2 Authors
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE.txt or copy at
+// https://www.boost.org/LICENSE_1_0.txt)
+
+// SPDX-License-Identifier: BSL-1.0
+#ifndef CATCH_LOGICAL_TRAITS_HPP_INCLUDED
+#define CATCH_LOGICAL_TRAITS_HPP_INCLUDED
+
+#include <type_traits>
+
+namespace Catch {
+namespace Detail {
+
+#if defined( __cpp_lib_logical_traits ) && __cpp_lib_logical_traits >= 201510
+
+ using std::conjunction;
+ using std::disjunction;
+ using std::negation;
+
+#else
+
+ template <class...> struct conjunction : std::true_type {};
+ template <class B1> struct conjunction<B1> : B1 {};
+ template <class B1, class... Bn>
+ struct conjunction<B1, Bn...>
+ : std::conditional_t<bool( B1::value ), conjunction<Bn...>, B1> {};
+
+ template <class...> struct disjunction : std::false_type {};
+ template <class B1> struct disjunction<B1> : B1 {};
+ template <class B1, class... Bn>
+ struct disjunction<B1, Bn...>
+ : std::conditional_t<bool( B1::value ), B1, disjunction<Bn...>> {};
+
+ template <class B>
+ struct negation : std::integral_constant<bool, !bool(B::value)> {};
+
+#endif
+
+} // namespace Detail
+} // namespace Catch
+
+#endif // CATCH_LOGICAL_TRAITS_HPP_INCLUDED