Add std::move/std::forward replacement macros

Using the `CATCH_MOVE` and `CATCH_FORWARD` macros instead of the
`std::move` and `std::forward<T>` utility functions can improve
compilation times and debug build's performance, and thus will
be preferred going forward.
This commit is contained in:
Martin Hořeňovský 2021-08-13 00:11:22 +02:00
parent 7040f03b54
commit 03ce304102
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
4 changed files with 22 additions and 0 deletions

View File

@ -99,6 +99,7 @@ set(INTERNAL_HEADERS
${SOURCES_DIR}/catch_message.hpp ${SOURCES_DIR}/catch_message.hpp
${SOURCES_DIR}/internal/catch_message_info.hpp ${SOURCES_DIR}/internal/catch_message_info.hpp
${SOURCES_DIR}/internal/catch_meta.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_option.hpp
${SOURCES_DIR}/internal/catch_output_redirect.hpp ${SOURCES_DIR}/internal/catch_output_redirect.hpp
${SOURCES_DIR}/internal/catch_platform.hpp ${SOURCES_DIR}/internal/catch_platform.hpp

View File

@ -72,6 +72,7 @@
#include <catch2/internal/catch_list.hpp> #include <catch2/internal/catch_list.hpp>
#include <catch2/internal/catch_message_info.hpp> #include <catch2/internal/catch_message_info.hpp>
#include <catch2/internal/catch_meta.hpp> #include <catch2/internal/catch_meta.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <catch2/internal/catch_noncopyable.hpp> #include <catch2/internal/catch_noncopyable.hpp>
#include <catch2/internal/catch_option.hpp> #include <catch2/internal/catch_option.hpp>
#include <catch2/internal/catch_output_redirect.hpp> #include <catch2/internal/catch_output_redirect.hpp>

View File

@ -8,6 +8,7 @@
#ifndef CATCH_SECTION_INFO_HPP_INCLUDED #ifndef CATCH_SECTION_INFO_HPP_INCLUDED
#define CATCH_SECTION_INFO_HPP_INCLUDED #define CATCH_SECTION_INFO_HPP_INCLUDED
#include <catch2/internal/catch_move_and_forward.hpp>
#include <catch2/internal/catch_source_line_info.hpp> #include <catch2/internal/catch_source_line_info.hpp>
#include <catch2/internal/catch_stringref.hpp> #include <catch2/internal/catch_stringref.hpp>
#include <catch2/catch_totals.hpp> #include <catch2/catch_totals.hpp>

View File

@ -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 <type_traits>
//! TODO: replaces std::move for better performance
#define CATCH_MOVE(...) static_cast<std::remove_reference_t<decltype(__VA_ARGS__)>&&>(__VA_ARGS__)
#define CATCH_FORWARD(...) static_cast<decltype(__VA_ARGS__)&&>(__VA_ARGS__)
#endif // CATCH_MOVE_AND_FORWARD_HPP_INCLUDED