mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-23 13:05:39 +02:00
Upgrade to C++17
This commit is contained in:
@@ -76,11 +76,9 @@ set(IMPL_HEADERS
|
||||
${SOURCES_DIR}/internal/catch_config_counter.hpp
|
||||
${SOURCES_DIR}/internal/catch_config_prefix_messages.hpp
|
||||
${SOURCES_DIR}/internal/catch_config_static_analysis_support.hpp
|
||||
${SOURCES_DIR}/internal/catch_config_uncaught_exceptions.hpp
|
||||
${SOURCES_DIR}/internal/catch_config_wchar.hpp
|
||||
${SOURCES_DIR}/internal/catch_console_colour.hpp
|
||||
${SOURCES_DIR}/internal/catch_console_width.hpp
|
||||
${SOURCES_DIR}/internal/catch_container_nonmembers.hpp
|
||||
${SOURCES_DIR}/internal/catch_context.hpp
|
||||
${SOURCES_DIR}/internal/catch_debug_console.hpp
|
||||
${SOURCES_DIR}/internal/catch_debugger.hpp
|
||||
@@ -99,7 +97,6 @@ set(IMPL_HEADERS
|
||||
${SOURCES_DIR}/internal/catch_lazy_expr.hpp
|
||||
${SOURCES_DIR}/internal/catch_leak_detector.hpp
|
||||
${SOURCES_DIR}/internal/catch_list.hpp
|
||||
${SOURCES_DIR}/internal/catch_logical_traits.hpp
|
||||
${SOURCES_DIR}/internal/catch_message_info.hpp
|
||||
${SOURCES_DIR}/internal/catch_meta.hpp
|
||||
${SOURCES_DIR}/internal/catch_move_and_forward.hpp
|
||||
@@ -365,8 +362,8 @@ set_target_properties(Catch2 PROPERTIES
|
||||
SOVERSION ${PROJECT_VERSION}
|
||||
)
|
||||
|
||||
# require C++14
|
||||
target_compile_features(Catch2 PUBLIC cxx_std_14)
|
||||
# require C++17
|
||||
target_compile_features(Catch2 PUBLIC cxx_std_17)
|
||||
|
||||
configure_file(
|
||||
"${SOURCES_DIR}/catch_user_config.hpp.in"
|
||||
@@ -450,7 +447,7 @@ if(CATCH_BUILD_EXAMPLES OR CATCH_BUILD_EXTRA_TESTS)
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
)
|
||||
target_compile_definitions(Catch2_buildall_interface INTERFACE CATCH_CONFIG_STATIC)
|
||||
target_compile_features(Catch2_buildall_interface INTERFACE cxx_std_14)
|
||||
target_compile_features(Catch2_buildall_interface INTERFACE cxx_std_17)
|
||||
endif()
|
||||
|
||||
list(APPEND CATCH_IMPL_TARGETS Catch2 Catch2WithMain)
|
||||
|
@@ -64,12 +64,12 @@ namespace Catch {
|
||||
}
|
||||
|
||||
template <typename Fn, typename... Args>
|
||||
inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> std::enable_if_t<!std::is_same<void, decltype(fn(args...))>::value> {
|
||||
inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> std::enable_if_t<!std::is_same_v<void, decltype(fn(args...))>> {
|
||||
deoptimize_value(CATCH_FORWARD(fn) (CATCH_FORWARD(args)...));
|
||||
}
|
||||
|
||||
template <typename Fn, typename... Args>
|
||||
inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> std::enable_if_t<std::is_same<void, decltype(fn(args...))>::value> {
|
||||
inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> std::enable_if_t<std::is_same_v<void, decltype(fn(args...))>> {
|
||||
CATCH_FORWARD((fn)) (CATCH_FORWARD(args)...);
|
||||
}
|
||||
} // namespace Benchmark
|
||||
|
@@ -46,7 +46,7 @@ namespace Catch {
|
||||
std::vector<FDuration> samples2;
|
||||
samples2.reserve(samples.size());
|
||||
for (auto s : samples) {
|
||||
samples2.push_back( FDuration( s ) );
|
||||
samples2.emplace_back( s );
|
||||
}
|
||||
|
||||
return {
|
||||
|
@@ -21,7 +21,7 @@ namespace Catch {
|
||||
namespace Benchmark {
|
||||
namespace Detail {
|
||||
template <typename T, typename U>
|
||||
static constexpr bool is_related_v = std::is_same<std::decay_t<T>, std::decay_t<U>>::value;
|
||||
static constexpr bool is_related_v = std::is_same_v<std::decay_t<T>, std::decay_t<U>>;
|
||||
|
||||
/// We need to reinvent std::function because every piece of code that might add overhead
|
||||
/// in a measurement context needs to have consistent performance characteristics so that we
|
||||
|
@@ -57,11 +57,9 @@
|
||||
#include <catch2/internal/catch_config_counter.hpp>
|
||||
#include <catch2/internal/catch_config_prefix_messages.hpp>
|
||||
#include <catch2/internal/catch_config_static_analysis_support.hpp>
|
||||
#include <catch2/internal/catch_config_uncaught_exceptions.hpp>
|
||||
#include <catch2/internal/catch_config_wchar.hpp>
|
||||
#include <catch2/internal/catch_console_colour.hpp>
|
||||
#include <catch2/internal/catch_console_width.hpp>
|
||||
#include <catch2/internal/catch_container_nonmembers.hpp>
|
||||
#include <catch2/internal/catch_context.hpp>
|
||||
#include <catch2/internal/catch_debug_console.hpp>
|
||||
#include <catch2/internal/catch_debugger.hpp>
|
||||
@@ -80,7 +78,6 @@
|
||||
#include <catch2/internal/catch_lazy_expr.hpp>
|
||||
#include <catch2/internal/catch_leak_detector.hpp>
|
||||
#include <catch2/internal/catch_list.hpp>
|
||||
#include <catch2/internal/catch_logical_traits.hpp>
|
||||
#include <catch2/internal/catch_message_info.hpp>
|
||||
#include <catch2/internal/catch_meta.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
@@ -29,7 +29,7 @@ namespace Catch {
|
||||
|
||||
Approx operator-() const;
|
||||
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible_v<double, T>>>
|
||||
Approx operator()( T const& value ) const {
|
||||
Approx approx( static_cast<double>(value) );
|
||||
approx.m_epsilon = m_epsilon;
|
||||
@@ -38,67 +38,67 @@ namespace Catch {
|
||||
return approx;
|
||||
}
|
||||
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible_v<double, T>>>
|
||||
explicit Approx( T const& value ): Approx(static_cast<double>(value))
|
||||
{}
|
||||
|
||||
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible_v<double, T>>>
|
||||
friend bool operator == ( const T& lhs, Approx const& rhs ) {
|
||||
auto lhs_v = static_cast<double>(lhs);
|
||||
return rhs.equalityComparisonImpl(lhs_v);
|
||||
}
|
||||
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible_v<double, T>>>
|
||||
friend bool operator == ( Approx const& lhs, const T& rhs ) {
|
||||
return operator==( rhs, lhs );
|
||||
}
|
||||
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible_v<double, T>>>
|
||||
friend bool operator != ( T const& lhs, Approx const& rhs ) {
|
||||
return !operator==( lhs, rhs );
|
||||
}
|
||||
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible_v<double, T>>>
|
||||
friend bool operator != ( Approx const& lhs, T const& rhs ) {
|
||||
return !operator==( rhs, lhs );
|
||||
}
|
||||
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible_v<double, T>>>
|
||||
friend bool operator <= ( T const& lhs, Approx const& rhs ) {
|
||||
return static_cast<double>(lhs) < rhs.m_value || lhs == rhs;
|
||||
}
|
||||
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible_v<double, T>>>
|
||||
friend bool operator <= ( Approx const& lhs, T const& rhs ) {
|
||||
return lhs.m_value < static_cast<double>(rhs) || lhs == rhs;
|
||||
}
|
||||
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible_v<double, T>>>
|
||||
friend bool operator >= ( T const& lhs, Approx const& rhs ) {
|
||||
return static_cast<double>(lhs) > rhs.m_value || lhs == rhs;
|
||||
}
|
||||
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible_v<double, T>>>
|
||||
friend bool operator >= ( Approx const& lhs, T const& rhs ) {
|
||||
return lhs.m_value > static_cast<double>(rhs) || lhs == rhs;
|
||||
}
|
||||
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible_v<double, T>>>
|
||||
Approx& epsilon( T const& newEpsilon ) {
|
||||
const auto epsilonAsDouble = static_cast<double>(newEpsilon);
|
||||
setEpsilon(epsilonAsDouble);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible_v<double, T>>>
|
||||
Approx& margin( T const& newMargin ) {
|
||||
const auto marginAsDouble = static_cast<double>(newMargin);
|
||||
setMargin(marginAsDouble);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
|
||||
template <typename T, typename = std::enable_if_t<std::is_constructible_v<double, T>>>
|
||||
Approx& scale( T const& newScale ) {
|
||||
m_scale = static_cast<double>(newScale);
|
||||
return *this;
|
||||
|
@@ -16,7 +16,6 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
// TODO: Use C++17 `inline` variables
|
||||
constexpr int UnspecifiedErrorExitCode = 1;
|
||||
constexpr int NoTestsRunExitCode = 2;
|
||||
constexpr int UnmatchedTestSpecExitCode = 3;
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#include <catch2/internal/catch_polyfills.hpp>
|
||||
|
||||
#include <iomanip>
|
||||
#include <cstddef>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@@ -135,11 +136,9 @@ std::string StringMaker<std::string>::convert(const std::string& str) {
|
||||
return Detail::convertIntoString( str );
|
||||
}
|
||||
|
||||
#ifdef CATCH_CONFIG_CPP17_STRING_VIEW
|
||||
std::string StringMaker<std::string_view>::convert(std::string_view str) {
|
||||
return Detail::convertIntoString( StringRef( str.data(), str.size() ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string StringMaker<char const*>::convert(char const* str) {
|
||||
if (str) {
|
||||
@@ -166,11 +165,9 @@ std::string StringMaker<std::wstring>::convert(const std::wstring& wstr) {
|
||||
return ::Catch::Detail::stringify(s);
|
||||
}
|
||||
|
||||
# ifdef CATCH_CONFIG_CPP17_STRING_VIEW
|
||||
std::string StringMaker<std::wstring_view>::convert(std::wstring_view str) {
|
||||
return StringMaker<std::wstring>::convert(std::wstring(str));
|
||||
}
|
||||
# endif
|
||||
|
||||
std::string StringMaker<wchar_t const*>::convert(wchar_t const * str) {
|
||||
if (str) {
|
||||
@@ -188,12 +185,9 @@ std::string StringMaker<wchar_t *>::convert(wchar_t * str) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CATCH_CONFIG_CPP17_BYTE)
|
||||
#include <cstddef>
|
||||
std::string StringMaker<std::byte>::convert(std::byte value) {
|
||||
return ::Catch::Detail::stringify(std::to_integer<unsigned long long>(value));
|
||||
}
|
||||
#endif // defined(CATCH_CONFIG_CPP17_BYTE)
|
||||
|
||||
std::string StringMaker<int>::convert(int value) {
|
||||
return ::Catch::Detail::stringify(static_cast<long long>(value));
|
||||
|
@@ -20,9 +20,7 @@
|
||||
#include <catch2/internal/catch_void_type.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_enum_values_registry.hpp>
|
||||
|
||||
#ifdef CATCH_CONFIG_CPP17_STRING_VIEW
|
||||
#include <string_view>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
@@ -78,13 +76,13 @@ namespace Catch {
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<
|
||||
!std::is_enum<T>::value && !std::is_base_of<std::exception, T>::value,
|
||||
!std::is_enum_v<T> && !std::is_base_of_v<std::exception, T>,
|
||||
std::string> convertUnstreamable( T const& ) {
|
||||
return std::string(Detail::unprintableString);
|
||||
}
|
||||
template<typename T>
|
||||
std::enable_if_t<
|
||||
!std::is_enum<T>::value && std::is_base_of<std::exception, T>::value,
|
||||
!std::is_enum_v<T> && std::is_base_of_v<std::exception, T>,
|
||||
std::string> convertUnstreamable(T const& ex) {
|
||||
return ex.what();
|
||||
}
|
||||
@@ -92,7 +90,7 @@ namespace Catch {
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<
|
||||
std::is_enum<T>::value,
|
||||
std::is_enum_v<T>,
|
||||
std::string> convertUnstreamable( T const& value ) {
|
||||
return convertUnknownEnumToString( value );
|
||||
}
|
||||
@@ -173,12 +171,10 @@ namespace Catch {
|
||||
static std::string convert(const std::string& str);
|
||||
};
|
||||
|
||||
#ifdef CATCH_CONFIG_CPP17_STRING_VIEW
|
||||
template<>
|
||||
struct StringMaker<std::string_view> {
|
||||
static std::string convert(std::string_view str);
|
||||
};
|
||||
#endif
|
||||
|
||||
template<>
|
||||
struct StringMaker<char const *> {
|
||||
@@ -195,12 +191,10 @@ namespace Catch {
|
||||
static std::string convert(const std::wstring& wstr);
|
||||
};
|
||||
|
||||
# ifdef CATCH_CONFIG_CPP17_STRING_VIEW
|
||||
template<>
|
||||
struct StringMaker<std::wstring_view> {
|
||||
static std::string convert(std::wstring_view str);
|
||||
};
|
||||
# endif
|
||||
|
||||
template<>
|
||||
struct StringMaker<wchar_t const *> {
|
||||
@@ -236,12 +230,10 @@ namespace Catch {
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(CATCH_CONFIG_CPP17_BYTE)
|
||||
template<>
|
||||
struct StringMaker<std::byte> {
|
||||
static std::string convert(std::byte value);
|
||||
};
|
||||
#endif // defined(CATCH_CONFIG_CPP17_BYTE)
|
||||
template<>
|
||||
struct StringMaker<int> {
|
||||
static std::string convert(int value);
|
||||
@@ -387,7 +379,7 @@ namespace Catch {
|
||||
}
|
||||
#endif // CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER
|
||||
|
||||
#if defined(CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER) && defined(CATCH_CONFIG_CPP17_OPTIONAL)
|
||||
#if defined(CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER)
|
||||
#include <optional>
|
||||
namespace Catch {
|
||||
template<typename T>
|
||||
@@ -417,7 +409,7 @@ namespace Catch {
|
||||
template<
|
||||
typename Tuple,
|
||||
std::size_t N = 0,
|
||||
bool = (N < std::tuple_size<Tuple>::value)
|
||||
bool = (N < std::tuple_size_v<Tuple>)
|
||||
>
|
||||
struct TupleElementPrinter {
|
||||
static void print(const Tuple& tuple, std::ostream& os) {
|
||||
@@ -451,7 +443,7 @@ namespace Catch {
|
||||
}
|
||||
#endif // CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER
|
||||
|
||||
#if defined(CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER) && defined(CATCH_CONFIG_CPP17_VARIANT)
|
||||
#if defined(CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER)
|
||||
#include <variant>
|
||||
namespace Catch {
|
||||
template<>
|
||||
|
@@ -60,56 +60,6 @@
|
||||
|
||||
|
||||
|
||||
#cmakedefine CATCH_CONFIG_CPP17_BYTE
|
||||
#cmakedefine CATCH_CONFIG_NO_CPP17_BYTE
|
||||
|
||||
#if defined( CATCH_CONFIG_CPP17_BYTE ) && \
|
||||
defined( CATCH_CONFIG_NO_CPP17_BYTE )
|
||||
# error Cannot force CPP17_BYTE to both ON and OFF
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#cmakedefine CATCH_CONFIG_CPP17_OPTIONAL
|
||||
#cmakedefine CATCH_CONFIG_NO_CPP17_OPTIONAL
|
||||
|
||||
#if defined( CATCH_CONFIG_CPP17_OPTIONAL ) && \
|
||||
defined( CATCH_CONFIG_NO_CPP17_OPTIONAL )
|
||||
# error Cannot force CPP17_OPTIONAL to both ON and OFF
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#cmakedefine CATCH_CONFIG_CPP17_STRING_VIEW
|
||||
#cmakedefine CATCH_CONFIG_NO_CPP17_STRING_VIEW
|
||||
|
||||
#if defined( CATCH_CONFIG_CPP17_STRING_VIEW ) && \
|
||||
defined( CATCH_CONFIG_NO_CPP17_STRING_VIEW )
|
||||
# error Cannot force CPP17_STRING_VIEW to both ON and OFF
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#cmakedefine CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
|
||||
#cmakedefine CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS
|
||||
|
||||
#if defined( CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS ) && \
|
||||
defined( CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS )
|
||||
# error Cannot force CPP17_UNCAUGHT_EXCEPTIONS to both ON and OFF
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#cmakedefine CATCH_CONFIG_CPP17_VARIANT
|
||||
#cmakedefine CATCH_CONFIG_NO_CPP17_VARIANT
|
||||
|
||||
#if defined( CATCH_CONFIG_CPP17_VARIANT ) && \
|
||||
defined( CATCH_CONFIG_NO_CPP17_VARIANT )
|
||||
# error Cannot force CPP17_VARIANT to both ON and OFF
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#cmakedefine CATCH_CONFIG_GLOBAL_NEXTAFTER
|
||||
#cmakedefine CATCH_CONFIG_NO_GLOBAL_NEXTAFTER
|
||||
|
||||
|
@@ -88,7 +88,7 @@ namespace Detail {
|
||||
|
||||
template<typename T>
|
||||
class FixedValuesGenerator final : public IGenerator<T> {
|
||||
static_assert(!std::is_same<T, bool>::value,
|
||||
static_assert(!std::is_same_v<T, bool>,
|
||||
"FixedValuesGenerator does not support bools because of std::vector<bool>"
|
||||
"specialization, use SingleValue Generator instead.");
|
||||
std::vector<T> m_values;
|
||||
@@ -131,7 +131,7 @@ namespace Detail {
|
||||
m_generators.emplace_back( value( CATCH_MOVE( val ) ) );
|
||||
}
|
||||
template <typename U>
|
||||
std::enable_if_t<!std::is_same<std::decay_t<U>, T>::value>
|
||||
std::enable_if_t<!std::is_same_v<std::decay_t<U>, T>>
|
||||
add_generator( U&& val ) {
|
||||
add_generator( T( CATCH_FORWARD( val ) ) );
|
||||
}
|
||||
|
@@ -58,7 +58,7 @@ namespace Generators {
|
||||
class FilterGenerator final : public IGenerator<T> {
|
||||
GeneratorWrapper<T> m_generator;
|
||||
Predicate m_predicate;
|
||||
static_assert(!std::is_reference<Predicate>::value, "This would most likely result in a dangling reference");
|
||||
static_assert(!std::is_reference_v<Predicate>, "This would most likely result in a dangling reference");
|
||||
public:
|
||||
template <typename P>
|
||||
FilterGenerator(P&& pred, GeneratorWrapper<T>&& generator):
|
||||
@@ -97,7 +97,7 @@ namespace Generators {
|
||||
|
||||
template <typename T>
|
||||
class RepeatGenerator final : public IGenerator<T> {
|
||||
static_assert(!std::is_same<T, bool>::value,
|
||||
static_assert(!std::is_same_v<T, bool>,
|
||||
"RepeatGenerator currently does not support bools"
|
||||
"because of std::vector<bool> specialization");
|
||||
GeneratorWrapper<T> m_generator;
|
||||
|
@@ -83,7 +83,7 @@ public:
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
std::enable_if_t<std::is_integral<T>::value, GeneratorWrapper<T>>
|
||||
std::enable_if_t<std::is_integral_v<T>, GeneratorWrapper<T>>
|
||||
random(T a, T b) {
|
||||
return GeneratorWrapper<T>(
|
||||
Catch::Detail::make_unique<RandomIntegerGenerator<T>>(a, b, Detail::getSeed())
|
||||
@@ -91,7 +91,7 @@ random(T a, T b) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::enable_if_t<std::is_floating_point<T>::value,
|
||||
std::enable_if_t<std::is_floating_point_v<T>,
|
||||
GeneratorWrapper<T>>
|
||||
random(T a, T b) {
|
||||
return GeneratorWrapper<T>(
|
||||
|
@@ -52,20 +52,20 @@ public:
|
||||
|
||||
template <typename T>
|
||||
GeneratorWrapper<T> range(T const& start, T const& end, T const& step) {
|
||||
static_assert(std::is_arithmetic<T>::value && !std::is_same<T, bool>::value, "Type must be numeric");
|
||||
static_assert(std::is_arithmetic_v<T> && !std::is_same_v<T, bool>, "Type must be numeric");
|
||||
return GeneratorWrapper<T>(Catch::Detail::make_unique<RangeGenerator<T>>(start, end, step));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GeneratorWrapper<T> range(T const& start, T const& end) {
|
||||
static_assert(std::is_integral<T>::value && !std::is_same<T, bool>::value, "Type must be an integer");
|
||||
static_assert(std::is_integral_v<T> && !std::is_same_v<T, bool>, "Type must be an integer");
|
||||
return GeneratorWrapper<T>(Catch::Detail::make_unique<RangeGenerator<T>>(start, end));
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
class IteratorGenerator final : public IGenerator<T> {
|
||||
static_assert(!std::is_same<T, bool>::value,
|
||||
static_assert(!std::is_same_v<T, bool>,
|
||||
"IteratorGenerator currently does not support bools"
|
||||
"because of std::vector<bool> specialization");
|
||||
|
||||
|
@@ -20,14 +20,7 @@
|
||||
# pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
#endif
|
||||
|
||||
#ifndef CLARA_CONFIG_OPTIONAL_TYPE
|
||||
# ifdef __has_include
|
||||
# if __has_include( <optional>) && __cplusplus >= 201703L
|
||||
# include <optional>
|
||||
# define CLARA_CONFIG_OPTIONAL_TYPE std::optional
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#include <optional>
|
||||
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
@@ -328,10 +321,9 @@ namespace Catch {
|
||||
std::string& target );
|
||||
ParserResult convertInto( std::string const& source, bool& target );
|
||||
|
||||
#ifdef CLARA_CONFIG_OPTIONAL_TYPE
|
||||
template <typename T>
|
||||
auto convertInto( std::string const& source,
|
||||
CLARA_CONFIG_OPTIONAL_TYPE<T>& target )
|
||||
std::optional<T>& target )
|
||||
-> ParserResult {
|
||||
T temp;
|
||||
auto result = convertInto( source, temp );
|
||||
@@ -339,7 +331,6 @@ namespace Catch {
|
||||
target = CATCH_MOVE( temp );
|
||||
return result;
|
||||
}
|
||||
#endif // CLARA_CONFIG_OPTIONAL_TYPE
|
||||
|
||||
struct BoundRef : Catch::Detail::NonCopyable {
|
||||
virtual ~BoundRef() = default;
|
||||
@@ -393,7 +384,7 @@ namespace Catch {
|
||||
|
||||
template <typename ReturnType> struct LambdaInvoker {
|
||||
static_assert(
|
||||
std::is_same<ReturnType, ParserResult>::value,
|
||||
std::is_same_v<ReturnType, ParserResult>,
|
||||
"Lambda must return void or clara::ParserResult" );
|
||||
|
||||
template <typename L, typename ArgType>
|
||||
@@ -449,8 +440,8 @@ namespace Catch {
|
||||
UnaryLambdaTraits<L>::isValid,
|
||||
"Supplied lambda must take exactly one argument" );
|
||||
static_assert(
|
||||
std::is_same<typename UnaryLambdaTraits<L>::ArgType,
|
||||
bool>::value,
|
||||
std::is_same_v<typename UnaryLambdaTraits<L>::ArgType,
|
||||
bool>,
|
||||
"flags must be boolean" );
|
||||
|
||||
explicit BoundFlagLambda( L const& lambda ):
|
||||
|
@@ -29,10 +29,6 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
# if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
|
||||
# define CATCH_CPP17_OR_GREATER
|
||||
# endif
|
||||
|
||||
# if (__cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
|
||||
# define CATCH_CPP20_OR_GREATER
|
||||
# endif
|
||||
@@ -198,8 +194,7 @@
|
||||
# define _BSD_SOURCE
|
||||
// some versions of cygwin (most) do not support std::to_string. Use the libstd check.
|
||||
// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813
|
||||
# if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \
|
||||
&& !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))
|
||||
# if !(defined(_GLIBCXX_USE_C99) && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))
|
||||
|
||||
# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING
|
||||
|
||||
@@ -275,43 +270,6 @@
|
||||
#define CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER
|
||||
#endif
|
||||
|
||||
// Various stdlib support checks that require __has_include
|
||||
#if defined(__has_include)
|
||||
// Check if string_view is available and usable
|
||||
#if __has_include(<string_view>) && defined(CATCH_CPP17_OR_GREATER)
|
||||
# define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW
|
||||
#endif
|
||||
|
||||
// Check if optional is available and usable
|
||||
# if __has_include(<optional>) && defined(CATCH_CPP17_OR_GREATER)
|
||||
# define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL
|
||||
# endif // __has_include(<optional>) && defined(CATCH_CPP17_OR_GREATER)
|
||||
|
||||
// Check if byte is available and usable
|
||||
# if __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER)
|
||||
# include <cstddef>
|
||||
# if defined(__cpp_lib_byte) && (__cpp_lib_byte > 0)
|
||||
# define CATCH_INTERNAL_CONFIG_CPP17_BYTE
|
||||
# endif
|
||||
# endif // __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER)
|
||||
|
||||
// Check if variant is available and usable
|
||||
# if __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER)
|
||||
# if defined(__clang__) && (__clang_major__ < 8)
|
||||
// work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852
|
||||
// fix should be in clang 8, workaround in libstdc++ 8.2
|
||||
# include <ciso646>
|
||||
# if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9)
|
||||
# define CATCH_CONFIG_NO_CPP17_VARIANT
|
||||
# else
|
||||
# define CATCH_INTERNAL_CONFIG_CPP17_VARIANT
|
||||
# endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9)
|
||||
# else
|
||||
# define CATCH_INTERNAL_CONFIG_CPP17_VARIANT
|
||||
# endif // defined(__clang__) && (__clang_major__ < 8)
|
||||
# endif // __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER)
|
||||
#endif // defined(__has_include)
|
||||
|
||||
|
||||
#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH)
|
||||
# define CATCH_CONFIG_WINDOWS_SEH
|
||||
@@ -329,22 +287,6 @@
|
||||
# define CATCH_CONFIG_CPP11_TO_STRING
|
||||
#endif
|
||||
|
||||
#if defined(CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_NO_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_CPP17_OPTIONAL)
|
||||
# define CATCH_CONFIG_CPP17_OPTIONAL
|
||||
#endif
|
||||
|
||||
#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW)
|
||||
# define CATCH_CONFIG_CPP17_STRING_VIEW
|
||||
#endif
|
||||
|
||||
#if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT)
|
||||
# define CATCH_CONFIG_CPP17_VARIANT
|
||||
#endif
|
||||
|
||||
#if defined(CATCH_INTERNAL_CONFIG_CPP17_BYTE) && !defined(CATCH_CONFIG_NO_CPP17_BYTE) && !defined(CATCH_CONFIG_CPP17_BYTE)
|
||||
# define CATCH_CONFIG_CPP17_BYTE
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT)
|
||||
# define CATCH_INTERNAL_CONFIG_NEW_CAPTURE
|
||||
|
@@ -1,46 +0,0 @@
|
||||
|
||||
// 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
|
||||
|
||||
/** \file
|
||||
* Wrapper for UNCAUGHT_EXCEPTIONS configuration option
|
||||
*
|
||||
* For some functionality, Catch2 requires to know whether there is
|
||||
* an active exception. Because `std::uncaught_exception` is deprecated
|
||||
* in C++17, we want to use `std::uncaught_exceptions` if possible.
|
||||
*/
|
||||
|
||||
#ifndef CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED
|
||||
#define CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED
|
||||
|
||||
#include <catch2/catch_user_config.hpp>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# if _MSC_VER >= 1900 // Visual Studio 2015 or newer
|
||||
# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#include <exception>
|
||||
|
||||
#if defined(__cpp_lib_uncaught_exceptions) \
|
||||
&& !defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS)
|
||||
|
||||
# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
|
||||
#endif // __cpp_lib_uncaught_exceptions
|
||||
|
||||
|
||||
#if defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) \
|
||||
&& !defined(CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) \
|
||||
&& !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS)
|
||||
|
||||
# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
|
||||
#endif // CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED
|
@@ -1,73 +0,0 @@
|
||||
|
||||
// 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_CONTAINER_NONMEMBERS_HPP_INCLUDED
|
||||
#define CATCH_CONTAINER_NONMEMBERS_HPP_INCLUDED
|
||||
|
||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <initializer_list>
|
||||
|
||||
// We want a simple polyfill over `std::empty`, `std::size` and so on
|
||||
// for C++14 or C++ libraries with incomplete support.
|
||||
// We also have to handle that MSVC std lib will happily provide these
|
||||
// under older standards.
|
||||
#if defined(CATCH_CPP17_OR_GREATER) || defined(_MSC_VER)
|
||||
|
||||
// We are already using this header either way, so there shouldn't
|
||||
// be much additional overhead in including it to get the feature
|
||||
// test macros
|
||||
#include <string>
|
||||
|
||||
# if !defined(__cpp_lib_nonmember_container_access)
|
||||
# define CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS
|
||||
# endif
|
||||
|
||||
#else
|
||||
#define CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
namespace Catch {
|
||||
namespace Detail {
|
||||
|
||||
#if defined(CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS)
|
||||
template <typename Container>
|
||||
constexpr auto empty(Container const& cont) -> decltype(cont.empty()) {
|
||||
return cont.empty();
|
||||
}
|
||||
template <typename T, std::size_t N>
|
||||
constexpr bool empty(const T (&)[N]) noexcept {
|
||||
// GCC < 7 does not support the const T(&)[] parameter syntax
|
||||
// so we have to ignore the length explicitly
|
||||
(void)N;
|
||||
return false;
|
||||
}
|
||||
template <typename T>
|
||||
constexpr bool empty(std::initializer_list<T> list) noexcept {
|
||||
return list.size() > 0;
|
||||
}
|
||||
|
||||
|
||||
template <typename Container>
|
||||
constexpr auto size(Container const& cont) -> decltype(cont.size()) {
|
||||
return cont.size();
|
||||
}
|
||||
template <typename T, std::size_t N>
|
||||
constexpr std::size_t size(const T(&)[N]) noexcept {
|
||||
return N;
|
||||
}
|
||||
#endif // CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS
|
||||
|
||||
} // end namespace Detail
|
||||
} // end namespace Catch
|
||||
|
||||
|
||||
|
||||
#endif // CATCH_CONTAINER_NONMEMBERS_HPP_INCLUDED
|
@@ -12,7 +12,6 @@
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
#include <catch2/internal/catch_compare_traits.hpp>
|
||||
#include <catch2/internal/catch_test_failure_exception.hpp>
|
||||
#include <catch2/internal/catch_logical_traits.hpp>
|
||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||
|
||||
#include <type_traits>
|
||||
@@ -129,7 +128,7 @@
|
||||
namespace Catch {
|
||||
|
||||
namespace Detail {
|
||||
// This was added in C++20, but we require only C++14 for now.
|
||||
// This was added in C++20, but we require only C++17 for now.
|
||||
template <typename T>
|
||||
using RemoveCVRef_t = std::remove_cv_t<std::remove_reference_t<T>>;
|
||||
}
|
||||
@@ -148,8 +147,8 @@ namespace Catch {
|
||||
template <typename T>
|
||||
struct capture_by_value
|
||||
: std::integral_constant<bool,
|
||||
std::is_arithmetic<T>::value ||
|
||||
std::is_enum<T>::value> {};
|
||||
std::is_arithmetic_v<T> ||
|
||||
std::is_enum_v<T>> {};
|
||||
|
||||
#if defined( CATCH_CONFIG_CPP20_COMPARE_OVERLOADS )
|
||||
template <>
|
||||
@@ -294,9 +293,9 @@ namespace Catch {
|
||||
template <typename RhsT> \
|
||||
constexpr friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \
|
||||
-> std::enable_if_t< \
|
||||
Detail::conjunction<Detail::is_##id##_comparable<LhsT, RhsT>, \
|
||||
Detail::negation<capture_by_value< \
|
||||
Detail::RemoveCVRef_t<RhsT>>>>::value, \
|
||||
std::conjunction_v<Detail::is_##id##_comparable<LhsT, RhsT>, \
|
||||
std::negation<capture_by_value< \
|
||||
Detail::RemoveCVRef_t<RhsT>>>>, \
|
||||
BinaryExpr<LhsT, RhsT const&>> { \
|
||||
return { \
|
||||
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
|
||||
@@ -304,8 +303,8 @@ namespace Catch {
|
||||
template <typename RhsT> \
|
||||
constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \
|
||||
-> std::enable_if_t< \
|
||||
Detail::conjunction<Detail::is_##id##_comparable<LhsT, RhsT>, \
|
||||
capture_by_value<RhsT>>::value, \
|
||||
std::conjunction_v<Detail::is_##id##_comparable<LhsT, RhsT>, \
|
||||
capture_by_value<RhsT>>, \
|
||||
BinaryExpr<LhsT, RhsT>> { \
|
||||
return { \
|
||||
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
|
||||
@@ -313,12 +312,12 @@ namespace Catch {
|
||||
template <typename RhsT> \
|
||||
constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \
|
||||
-> std::enable_if_t< \
|
||||
Detail::conjunction< \
|
||||
Detail::negation<Detail::is_##id##_comparable<LhsT, RhsT>>, \
|
||||
std::conjunction_v< \
|
||||
std::negation<Detail::is_##id##_comparable<LhsT, RhsT>>, \
|
||||
Detail::is_eq_0_comparable<LhsT>, \
|
||||
/* We allow long because we want `ptr op NULL` to be accepted */ \
|
||||
Detail::disjunction<std::is_same<RhsT, int>, \
|
||||
std::is_same<RhsT, long>>>::value, \
|
||||
std::disjunction<std::is_same<RhsT, int>, \
|
||||
std::is_same<RhsT, long>>>, \
|
||||
BinaryExpr<LhsT, RhsT>> { \
|
||||
if ( rhs != 0 ) { throw_test_failure_exception(); } \
|
||||
return { \
|
||||
@@ -327,12 +326,12 @@ namespace Catch {
|
||||
template <typename RhsT> \
|
||||
constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \
|
||||
-> std::enable_if_t< \
|
||||
Detail::conjunction< \
|
||||
Detail::negation<Detail::is_##id##_comparable<LhsT, RhsT>>, \
|
||||
std::conjunction_v< \
|
||||
std::negation<Detail::is_##id##_comparable<LhsT, RhsT>>, \
|
||||
Detail::is_eq_0_comparable<RhsT>, \
|
||||
/* We allow long because we want `ptr op NULL` to be accepted */ \
|
||||
Detail::disjunction<std::is_same<LhsT, int>, \
|
||||
std::is_same<LhsT, long>>>::value, \
|
||||
std::disjunction<std::is_same<LhsT, int>, \
|
||||
std::is_same<LhsT, long>>>, \
|
||||
BinaryExpr<LhsT, RhsT>> { \
|
||||
if ( lhs.m_lhs != 0 ) { throw_test_failure_exception(); } \
|
||||
return { static_cast<bool>( 0 op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
|
||||
@@ -348,9 +347,9 @@ namespace Catch {
|
||||
template <typename RhsT> \
|
||||
constexpr friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \
|
||||
-> std::enable_if_t< \
|
||||
Detail::conjunction<Detail::is_##id##_comparable<LhsT, RhsT>, \
|
||||
Detail::negation<capture_by_value< \
|
||||
Detail::RemoveCVRef_t<RhsT>>>>::value, \
|
||||
std::conjunction_v<Detail::is_##id##_comparable<LhsT, RhsT>, \
|
||||
std::negation<capture_by_value< \
|
||||
Detail::RemoveCVRef_t<RhsT>>>>, \
|
||||
BinaryExpr<LhsT, RhsT const&>> { \
|
||||
return { \
|
||||
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
|
||||
@@ -358,8 +357,8 @@ namespace Catch {
|
||||
template <typename RhsT> \
|
||||
constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \
|
||||
-> std::enable_if_t< \
|
||||
Detail::conjunction<Detail::is_##id##_comparable<LhsT, RhsT>, \
|
||||
capture_by_value<RhsT>>::value, \
|
||||
std::conjunction_v<Detail::is_##id##_comparable<LhsT, RhsT>, \
|
||||
capture_by_value<RhsT>> , \
|
||||
BinaryExpr<LhsT, RhsT>> { \
|
||||
return { \
|
||||
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
|
||||
@@ -367,10 +366,10 @@ namespace Catch {
|
||||
template <typename RhsT> \
|
||||
constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \
|
||||
-> std::enable_if_t< \
|
||||
Detail::conjunction< \
|
||||
Detail::negation<Detail::is_##id##_comparable<LhsT, RhsT>>, \
|
||||
std::conjunction_v< \
|
||||
std::negation<Detail::is_##id##_comparable<LhsT, RhsT>>, \
|
||||
Detail::is_##id##_0_comparable<LhsT>, \
|
||||
std::is_same<RhsT, int>>::value, \
|
||||
std::is_same<RhsT, int>>, \
|
||||
BinaryExpr<LhsT, RhsT>> { \
|
||||
if ( rhs != 0 ) { throw_test_failure_exception(); } \
|
||||
return { \
|
||||
@@ -379,10 +378,10 @@ namespace Catch {
|
||||
template <typename RhsT> \
|
||||
constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \
|
||||
-> std::enable_if_t< \
|
||||
Detail::conjunction< \
|
||||
Detail::negation<Detail::is_##id##_comparable<LhsT, RhsT>>, \
|
||||
std::conjunction_v< \
|
||||
std::negation<Detail::is_##id##_comparable<LhsT, RhsT>>, \
|
||||
Detail::is_##id##_0_comparable<RhsT>, \
|
||||
std::is_same<LhsT, int>>::value, \
|
||||
std::is_same<LhsT, int>>, \
|
||||
BinaryExpr<LhsT, RhsT>> { \
|
||||
if ( lhs.m_lhs != 0 ) { throw_test_failure_exception(); } \
|
||||
return { static_cast<bool>( 0 op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
|
||||
|
@@ -49,7 +49,7 @@ namespace Catch {
|
||||
|
||||
template <typename ForwardIter, typename Sentinel>
|
||||
constexpr
|
||||
std::enable_if_t<!std::is_same<ForwardIter, Sentinel>::value,
|
||||
std::enable_if_t<!std::is_same_v<ForwardIter, Sentinel>,
|
||||
std::ptrdiff_t>
|
||||
sentinel_distance( ForwardIter iter, const Sentinel sentinel ) {
|
||||
std::ptrdiff_t dist = 0;
|
||||
|
@@ -35,7 +35,7 @@ namespace Catch {
|
||||
|
||||
template <typename T>
|
||||
void write( T const& value ) && {
|
||||
writeImpl( value, !std::is_arithmetic<T>::value );
|
||||
writeImpl( value, !std::is_arithmetic_v<T> );
|
||||
}
|
||||
void write( StringRef value ) &&;
|
||||
void write( bool value ) &&;
|
||||
@@ -49,7 +49,7 @@ namespace Catch {
|
||||
// and multiple iteration over the strings
|
||||
template <typename T,
|
||||
typename = typename std::enable_if_t<
|
||||
!std::is_convertible<T, StringRef>::value>>
|
||||
!std::is_convertible_v<T, StringRef>>>
|
||||
void writeImpl( T const& value, bool quote_value ) {
|
||||
m_sstream << value;
|
||||
writeImpl( m_sstream.str(), quote_value );
|
||||
|
@@ -1,44 +0,0 @@
|
||||
|
||||
// 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
|
@@ -27,16 +27,8 @@ namespace Catch {
|
||||
template <typename Fun, typename... Args>
|
||||
struct is_callable<Fun(Args...)> : decltype(is_callable_tester::test<Fun, Args...>(0)) {};
|
||||
|
||||
|
||||
#if defined(__cpp_lib_is_invocable) && __cpp_lib_is_invocable >= 201703
|
||||
// std::result_of is deprecated in C++17 and removed in C++20. Hence, it is
|
||||
// replaced with std::invoke_result here.
|
||||
template <typename Func, typename... U>
|
||||
using FunctionReturnType = std::remove_reference_t<std::remove_cv_t<std::invoke_result_t<Func, U...>>>;
|
||||
#else
|
||||
template <typename Func, typename... U>
|
||||
using FunctionReturnType = std::remove_reference_t<std::remove_cv_t<std::result_of_t<Func(U...)>>>;
|
||||
#endif
|
||||
|
||||
} // namespace Catch
|
||||
|
||||
|
@@ -311,23 +311,6 @@ namespace Catch {
|
||||
}
|
||||
}
|
||||
|
||||
RedirectGuard::RedirectGuard( RedirectGuard&& rhs ) noexcept:
|
||||
m_redirect( rhs.m_redirect ),
|
||||
m_activate( rhs.m_activate ),
|
||||
m_previouslyActive( rhs.m_previouslyActive ),
|
||||
m_moved( false ) {
|
||||
rhs.m_moved = true;
|
||||
}
|
||||
|
||||
RedirectGuard& RedirectGuard::operator=( RedirectGuard&& rhs ) noexcept {
|
||||
m_redirect = rhs.m_redirect;
|
||||
m_activate = rhs.m_activate;
|
||||
m_previouslyActive = rhs.m_previouslyActive;
|
||||
m_moved = false;
|
||||
rhs.m_moved = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
} // namespace Catch
|
||||
|
||||
#if defined( CATCH_CONFIG_NEW_CAPTURE )
|
||||
|
@@ -63,10 +63,6 @@ namespace Catch {
|
||||
|
||||
RedirectGuard( RedirectGuard const& ) = delete;
|
||||
RedirectGuard& operator=( RedirectGuard const& ) = delete;
|
||||
|
||||
// C++14 needs move-able guards to return them from functions
|
||||
RedirectGuard( RedirectGuard&& rhs ) noexcept;
|
||||
RedirectGuard& operator=( RedirectGuard&& rhs ) noexcept;
|
||||
};
|
||||
|
||||
RedirectGuard scopedActivate( OutputRedirect& redirectImpl );
|
||||
|
@@ -27,7 +27,7 @@ namespace Catch {
|
||||
*/
|
||||
template <typename FloatType>
|
||||
FloatType gamma(FloatType a, FloatType b) {
|
||||
static_assert( std::is_floating_point<FloatType>::value,
|
||||
static_assert( std::is_floating_point_v<FloatType>,
|
||||
"gamma returns the largest ULP magnitude within "
|
||||
"floating point range [a, b]. This only makes sense "
|
||||
"for floating point types" );
|
||||
|
@@ -122,7 +122,7 @@ namespace Catch {
|
||||
|
||||
template <typename UInt>
|
||||
constexpr ExtendedMultResult<UInt> extendedMult( UInt lhs, UInt rhs ) {
|
||||
static_assert( std::is_unsigned<UInt>::value,
|
||||
static_assert( std::is_unsigned_v<UInt>,
|
||||
"extendedMult can only handle unsigned integers" );
|
||||
static_assert( sizeof( UInt ) < sizeof( std::uint64_t ),
|
||||
"Generic extendedMult can only handle types smaller "
|
||||
@@ -141,7 +141,7 @@ namespace Catch {
|
||||
std::enable_if_t<sizeof(typename Generator::result_type) >= sizeof(TargetType),
|
||||
TargetType> fillBitsFrom(Generator& gen) {
|
||||
using gresult_type = typename Generator::result_type;
|
||||
static_assert( std::is_unsigned<TargetType>::value, "Only unsigned integers are supported" );
|
||||
static_assert( std::is_unsigned_v<TargetType>, "Only unsigned integers are supported" );
|
||||
static_assert( Generator::min() == 0 &&
|
||||
Generator::max() == static_cast<gresult_type>( -1 ),
|
||||
"Generator must be able to output all numbers in its result type (effectively it must be a random bit generator)" );
|
||||
@@ -160,7 +160,7 @@ namespace Catch {
|
||||
std::enable_if_t<sizeof(typename Generator::result_type) < sizeof(TargetType),
|
||||
TargetType> fillBitsFrom(Generator& gen) {
|
||||
using gresult_type = typename Generator::result_type;
|
||||
static_assert( std::is_unsigned<TargetType>::value,
|
||||
static_assert( std::is_unsigned_v<TargetType>,
|
||||
"Only unsigned integers are supported" );
|
||||
static_assert( Generator::min() == 0 &&
|
||||
Generator::max() == static_cast<gresult_type>( -1 ),
|
||||
@@ -188,12 +188,12 @@ namespace Catch {
|
||||
*/
|
||||
template <typename OriginalType, typename UnsignedType>
|
||||
constexpr
|
||||
std::enable_if_t<std::is_signed<OriginalType>::value, UnsignedType>
|
||||
std::enable_if_t<std::is_signed_v<OriginalType>, UnsignedType>
|
||||
transposeToNaturalOrder( UnsignedType in ) {
|
||||
static_assert(
|
||||
sizeof( OriginalType ) == sizeof( UnsignedType ),
|
||||
"reordering requires the same sized types on both sides" );
|
||||
static_assert( std::is_unsigned<UnsignedType>::value,
|
||||
static_assert( std::is_unsigned_v<UnsignedType>,
|
||||
"Input type must be unsigned" );
|
||||
// Assuming 2s complement (standardized in current C++), the
|
||||
// positive and negative numbers are already internally ordered,
|
||||
@@ -209,12 +209,12 @@ namespace Catch {
|
||||
template <typename OriginalType,
|
||||
typename UnsignedType>
|
||||
constexpr
|
||||
std::enable_if_t<std::is_unsigned<OriginalType>::value, UnsignedType>
|
||||
std::enable_if_t<std::is_unsigned_v<OriginalType>, UnsignedType>
|
||||
transposeToNaturalOrder(UnsignedType in) {
|
||||
static_assert(
|
||||
sizeof( OriginalType ) == sizeof( UnsignedType ),
|
||||
"reordering requires the same sized types on both sides" );
|
||||
static_assert( std::is_unsigned<UnsignedType>::value, "Input type must be unsigned" );
|
||||
static_assert( std::is_unsigned_v<UnsignedType>, "Input type must be unsigned" );
|
||||
// No reordering is needed for unsigned -> unsigned
|
||||
return in;
|
||||
}
|
||||
|
@@ -114,8 +114,7 @@ namespace Catch {
|
||||
|
||||
// First part is always reporter name, so we skip it
|
||||
for ( size_t i = 1; i < parts.size(); ++i ) {
|
||||
auto kv = splitKVPair( parts[i] );
|
||||
auto key = kv.key, value = kv.value;
|
||||
const auto [key, value] = splitKVPair( parts[i] );
|
||||
|
||||
if ( key.empty() || value.empty() ) { // NOLINT(bugprone-branch-clone)
|
||||
return {};
|
||||
@@ -126,7 +125,7 @@ namespace Catch {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto ret = kvPairs.emplace( std::string(kv.key), std::string(kv.value) );
|
||||
auto ret = kvPairs.emplace( std::string(key), std::string(value) );
|
||||
if ( !ret.second ) {
|
||||
// Duplicated key. We might want to handle this differently,
|
||||
// e.g. by overwriting the existing value?
|
||||
@@ -137,7 +136,7 @@ namespace Catch {
|
||||
if ( outputFileName ) {
|
||||
return {};
|
||||
}
|
||||
outputFileName = static_cast<std::string>( value );
|
||||
outputFileName = std::string( value );
|
||||
} else if ( key == "colour-mode" ) {
|
||||
// Duplicated key
|
||||
if ( colourMode ) {
|
||||
|
@@ -7,7 +7,6 @@
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
||||
#include <catch2/internal/catch_uncaught_exceptions.hpp>
|
||||
#include <catch2/internal/catch_config_uncaught_exceptions.hpp>
|
||||
#include <catch2/catch_user_config.hpp>
|
||||
|
||||
#include <exception>
|
||||
@@ -16,10 +15,8 @@ namespace Catch {
|
||||
bool uncaught_exceptions() {
|
||||
#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
|
||||
return false;
|
||||
#elif defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS)
|
||||
return std::uncaught_exceptions() > 0;
|
||||
#else
|
||||
return std::uncaught_exception();
|
||||
return std::uncaught_exceptions() > 0;
|
||||
#endif
|
||||
}
|
||||
} // end namespace Catch
|
||||
|
@@ -67,8 +67,8 @@ namespace Catch {
|
||||
*/
|
||||
template <typename FloatType>
|
||||
class uniform_floating_point_distribution {
|
||||
static_assert(std::is_floating_point<FloatType>::value, "...");
|
||||
static_assert(!std::is_same<FloatType, long double>::value,
|
||||
static_assert(std::is_floating_point_v<FloatType>, "...");
|
||||
static_assert(!std::is_same_v<FloatType, long double>,
|
||||
"We do not support long double due to inconsistent behaviour between platforms");
|
||||
|
||||
using WidthType = Detail::DistanceType<FloatType>;
|
||||
|
@@ -26,7 +26,7 @@ namespace Catch {
|
||||
*/
|
||||
template <typename IntegerType>
|
||||
class uniform_integer_distribution {
|
||||
static_assert(std::is_integral<IntegerType>::value, "...");
|
||||
static_assert(std::is_integral_v<IntegerType>, "...");
|
||||
|
||||
using UnsignedIntegerType = Detail::SizedUnsignedType_t<sizeof(IntegerType)>;
|
||||
|
||||
|
@@ -31,12 +31,12 @@ namespace Detail {
|
||||
m_ptr(ptr)
|
||||
{}
|
||||
|
||||
template <typename U, typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
||||
template <typename U, typename = std::enable_if_t<std::is_base_of_v<T, U>>>
|
||||
unique_ptr(unique_ptr<U>&& from):
|
||||
m_ptr(from.release())
|
||||
{}
|
||||
|
||||
template <typename U, typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
||||
template <typename U, typename = std::enable_if_t<std::is_base_of_v<T, U>>>
|
||||
unique_ptr& operator=(unique_ptr<U>&& from) {
|
||||
reset(from.release());
|
||||
|
||||
|
@@ -81,7 +81,7 @@ namespace Catch {
|
||||
// While it would still work, it would cause code bloat
|
||||
// and multiple iteration over the strings
|
||||
typename = typename std::enable_if_t<
|
||||
!std::is_convertible<T, StringRef>::value>>
|
||||
!std::is_convertible_v<T, StringRef>>>
|
||||
ScopedElement& writeAttribute( StringRef name,
|
||||
T const& attribute ) {
|
||||
m_writer->writeAttribute( name, attribute );
|
||||
@@ -122,7 +122,7 @@ namespace Catch {
|
||||
// While it would still work, it would cause code bloat
|
||||
// and multiple iteration over the strings
|
||||
typename = typename std::enable_if_t<
|
||||
!std::is_convertible<T, StringRef>::value>>
|
||||
!std::is_convertible_v<T, StringRef>>>
|
||||
XmlWriter& writeAttribute( StringRef name, T const& attribute ) {
|
||||
ReusableStringStream rss;
|
||||
rss << attribute;
|
||||
|
@@ -9,7 +9,6 @@
|
||||
#define CATCH_MATCHERS_CONTAINER_PROPERTIES_HPP_INCLUDED
|
||||
|
||||
#include <catch2/matchers/catch_matchers_templated.hpp>
|
||||
#include <catch2/internal/catch_container_nonmembers.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
namespace Catch {
|
||||
|
@@ -49,7 +49,7 @@ public:
|
||||
template<typename T, typename Pred>
|
||||
PredicateMatcher<T, Pred> Predicate(Pred&& predicate, std::string const& description = "") {
|
||||
static_assert(is_callable<Pred(T)>::value, "Predicate not callable with argument T");
|
||||
static_assert(std::is_same<bool, FunctionReturnType<Pred, T>>::value, "Predicate does not return bool");
|
||||
static_assert(std::is_same_v<bool, FunctionReturnType<Pred, T>>, "Predicate does not return bool");
|
||||
return PredicateMatcher<T, Pred>(CATCH_FORWARD(predicate), description);
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,6 @@
|
||||
#include <catch2/matchers/catch_matchers.hpp>
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
#include <catch2/internal/catch_logical_traits.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
@@ -58,19 +57,19 @@ namespace Matchers {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static constexpr bool is_generic_matcher_v = std::is_base_of<
|
||||
static constexpr bool is_generic_matcher_v = std::is_base_of_v<
|
||||
Catch::Matchers::MatcherGenericBase,
|
||||
std::remove_cv_t<std::remove_reference_t<T>>
|
||||
>::value;
|
||||
>;
|
||||
|
||||
template<typename... Ts>
|
||||
static constexpr bool are_generic_matchers_v = Catch::Detail::conjunction<std::integral_constant<bool,is_generic_matcher_v<Ts>>...>::value;
|
||||
static constexpr bool are_generic_matchers_v = std::conjunction_v<std::integral_constant<bool,is_generic_matcher_v<Ts>>...>;
|
||||
|
||||
template<typename T>
|
||||
static constexpr bool is_matcher_v = std::is_base_of<
|
||||
static constexpr bool is_matcher_v = std::is_base_of_v<
|
||||
Catch::Matchers::MatcherUntypedBase,
|
||||
std::remove_cv_t<std::remove_reference_t<T>>
|
||||
>::value;
|
||||
>;
|
||||
|
||||
|
||||
template<std::size_t N, typename Arg>
|
||||
|
@@ -117,17 +117,17 @@ namespace Matchers {
|
||||
std::string describe() const override {
|
||||
return "is approx: " + ::Catch::Detail::stringify( m_comparator );
|
||||
}
|
||||
template <typename = std::enable_if_t<std::is_constructible<double, T>::value>>
|
||||
template <typename = std::enable_if_t<std::is_constructible_v<double, T>>>
|
||||
ApproxMatcher& epsilon( T const& newEpsilon ) {
|
||||
approx.epsilon(static_cast<double>(newEpsilon));
|
||||
return *this;
|
||||
}
|
||||
template <typename = std::enable_if_t<std::is_constructible<double, T>::value>>
|
||||
template <typename = std::enable_if_t<std::is_constructible_v<double, T>>>
|
||||
ApproxMatcher& margin( T const& newMargin ) {
|
||||
approx.margin(static_cast<double>(newMargin));
|
||||
return *this;
|
||||
}
|
||||
template <typename = std::enable_if_t<std::is_constructible<double, T>::value>>
|
||||
template <typename = std::enable_if_t<std::is_constructible_v<double, T>>>
|
||||
ApproxMatcher& scale( T const& newScale ) {
|
||||
approx.scale(static_cast<double>(newScale));
|
||||
return *this;
|
||||
|
@@ -83,11 +83,9 @@ internal_headers = [
|
||||
'internal/catch_config_counter.hpp',
|
||||
'internal/catch_config_prefix_messages.hpp',
|
||||
'internal/catch_config_static_analysis_support.hpp',
|
||||
'internal/catch_config_uncaught_exceptions.hpp',
|
||||
'internal/catch_config_wchar.hpp',
|
||||
'internal/catch_console_colour.hpp',
|
||||
'internal/catch_console_width.hpp',
|
||||
'internal/catch_container_nonmembers.hpp',
|
||||
'internal/catch_context.hpp',
|
||||
'internal/catch_debug_console.hpp',
|
||||
'internal/catch_debugger.hpp',
|
||||
@@ -106,7 +104,6 @@ internal_headers = [
|
||||
'internal/catch_lazy_expr.hpp',
|
||||
'internal/catch_leak_detector.hpp',
|
||||
'internal/catch_list.hpp',
|
||||
'internal/catch_logical_traits.hpp',
|
||||
'internal/catch_message_info.hpp',
|
||||
'internal/catch_meta.hpp',
|
||||
'internal/catch_move_and_forward.hpp',
|
||||
@@ -374,7 +371,7 @@ if get_option('install')
|
||||
pkg.generate(
|
||||
catch2,
|
||||
filebase: 'catch2',
|
||||
description: 'A modern, C++-native, test framework for C++14 and above',
|
||||
description: 'A modern, C++-native, test framework for C++17 and above',
|
||||
url: 'https://github.com/catchorg/Catch2',
|
||||
)
|
||||
endif
|
||||
@@ -396,7 +393,7 @@ if get_option('install')
|
||||
pkg.generate(
|
||||
catch2_with_main,
|
||||
filebase: 'catch2-with-main',
|
||||
description: 'A modern, C++-native, test framework for C++14 and above (links in default main)',
|
||||
description: 'A modern, C++-native, test framework for C++17 and above (links in default main)',
|
||||
requires: 'catch2 = ' + meson.project_version(),
|
||||
)
|
||||
endif
|
||||
|
Reference in New Issue
Block a user