Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Add CATCH_ATTR_LIFETIMEBOUND macro polyfill over lifetimebound attr

Commit
8219ed79f29420c89748ae5eb8810946cefd491d
Author
Martin Hořeňovský ·
Parents
b3fb4b9feafc

Files · Download .tar.gz

Changes

 src/CMakeLists.txt                          |  1 +
 src/catch2/catch_all.hpp                    |  1 +
 src/catch2/internal/catch_lifetimebound.hpp | 24 ++++++++++++++++++++++++
 src/catch2/meson.build                      |  1 +
 4 files changed, 27 insertions(+)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1e3af147..554346f4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -98,6 +98,7 @@ set(IMPL_HEADERS
   ${SOURCES_DIR}/internal/catch_jsonwriter.hpp
   ${SOURCES_DIR}/internal/catch_lazy_expr.hpp
   ${SOURCES_DIR}/internal/catch_leak_detector.hpp
+  ${SOURCES_DIR}/internal/catch_lifetimebound.hpp
   ${SOURCES_DIR}/internal/catch_list.hpp
   ${SOURCES_DIR}/internal/catch_logical_traits.hpp
   ${SOURCES_DIR}/internal/catch_message_info.hpp
diff --git a/src/catch2/catch_all.hpp b/src/catch2/catch_all.hpp
index 2417d856..3dc4609e 100644
--- a/src/catch2/catch_all.hpp
+++ b/src/catch2/catch_all.hpp
@@ -79,6 +79,7 @@
 #include <catch2/internal/catch_jsonwriter.hpp>
 #include <catch2/internal/catch_lazy_expr.hpp>
 #include <catch2/internal/catch_leak_detector.hpp>
+#include <catch2/internal/catch_lifetimebound.hpp>
 #include <catch2/internal/catch_list.hpp>
 #include <catch2/internal/catch_logical_traits.hpp>
 #include <catch2/internal/catch_message_info.hpp>
diff --git a/src/catch2/internal/catch_lifetimebound.hpp b/src/catch2/internal/catch_lifetimebound.hpp
new file mode 100644
index 00000000..8114dc70
--- /dev/null
+++ b/src/catch2/internal/catch_lifetimebound.hpp
@@ -0,0 +1,24 @@
+
+//              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_LIFETIMEBOUND_HPP_INCLUDED
+#define CATCH_LIFETIMEBOUND_HPP_INCLUDED
+
+#if !defined( __has_cpp_attribute )
+#    define CATCH_ATTR_LIFETIMEBOUND
+#elif __has_cpp_attribute( msvc::lifetimebound )
+#    define CATCH_ATTR_LIFETIMEBOUND [[msvc::lifetimebound]]
+#elif __has_cpp_attribute( clang::lifetimebound )
+#    define CATCH_ATTR_LIFETIMEBOUND [[clang::lifetimebound]]
+#elif __has_cpp_attribute( lifetimebound )
+#    define CATCH_ATTR_LIFETIMEBOUND [[lifetimebound]]
+#else
+#    define CATCH_ATTR_LIFETIMEBOUND
+#endif
+
+#endif // CATCH_LIFETIMEBOUND_HPP_INCLUDED
diff --git a/src/catch2/meson.build b/src/catch2/meson.build
index 60f7777a..273e330f 100644
--- a/src/catch2/meson.build
+++ b/src/catch2/meson.build
@@ -105,6 +105,7 @@ internal_headers = [
   'internal/catch_jsonwriter.hpp',
   'internal/catch_lazy_expr.hpp',
   'internal/catch_leak_detector.hpp',
+  'internal/catch_lifetimebound.hpp',
   'internal/catch_list.hpp',
   'internal/catch_logical_traits.hpp',
   'internal/catch_message_info.hpp',