From 03ce304102829d438a0e3249b86094a6da802dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Fri, 13 Aug 2021 00:11:22 +0200 Subject: [PATCH] Add std::move/std::forward replacement macros Using the `CATCH_MOVE` and `CATCH_FORWARD` macros instead of the `std::move` and `std::forward` utility functions can improve compilation times and debug build's performance, and thus will be preferred going forward. --- src/CMakeLists.txt | 1 + src/catch2/catch_all.hpp | 1 + src/catch2/catch_section_info.hpp | 1 + .../internal/catch_move_and_forward.hpp | 19 +++++++++++++++++++ 4 files changed, 22 insertions(+) create mode 100644 src/catch2/internal/catch_move_and_forward.hpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5d7aa8c3..26ebdf09 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -99,6 +99,7 @@ set(INTERNAL_HEADERS ${SOURCES_DIR}/catch_message.hpp ${SOURCES_DIR}/internal/catch_message_info.hpp ${SOURCES_DIR}/internal/catch_meta.hpp + ${SOURCES_DIR}/internal/catch_move_and_forward.hpp ${SOURCES_DIR}/internal/catch_option.hpp ${SOURCES_DIR}/internal/catch_output_redirect.hpp ${SOURCES_DIR}/internal/catch_platform.hpp diff --git a/src/catch2/catch_all.hpp b/src/catch2/catch_all.hpp index 6b8ecf4e..35bd9741 100644 --- a/src/catch2/catch_all.hpp +++ b/src/catch2/catch_all.hpp @@ -72,6 +72,7 @@ #include #include #include +#include #include #include #include diff --git a/src/catch2/catch_section_info.hpp b/src/catch2/catch_section_info.hpp index df0732ec..b80d8b92 100644 --- a/src/catch2/catch_section_info.hpp +++ b/src/catch2/catch_section_info.hpp @@ -8,6 +8,7 @@ #ifndef CATCH_SECTION_INFO_HPP_INCLUDED #define CATCH_SECTION_INFO_HPP_INCLUDED +#include #include #include #include diff --git a/src/catch2/internal/catch_move_and_forward.hpp b/src/catch2/internal/catch_move_and_forward.hpp new file mode 100644 index 00000000..70520308 --- /dev/null +++ b/src/catch2/internal/catch_move_and_forward.hpp @@ -0,0 +1,19 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 +#ifndef CATCH_MOVE_AND_FORWARD_HPP_INCLUDED +#define CATCH_MOVE_AND_FORWARD_HPP_INCLUDED + +#include + +//! TODO: replaces std::move for better performance +#define CATCH_MOVE(...) static_cast&&>(__VA_ARGS__) + +#define CATCH_FORWARD(...) static_cast(__VA_ARGS__) + +#endif // CATCH_MOVE_AND_FORWARD_HPP_INCLUDED + \ No newline at end of file