diff options
| author | Leitwolf11 | 2026-10-31 13:00:24 +0300 |
|---|---|---|
| committer | Leitwolf11 | 2026-10-31 13:00:24 +0300 |
| commit | 8814bd0b796b2e291fa5b4a1033f0313c8a26065 (patch) | |
| tree | e87e5f5150f3712bb05ed53911425600aa871f45 /src/Progmasoft/Catch3/Generators | |
| parent | 6a42cdf6461b2577106ef094d6f98025554b6077 (diff) | |
| download | catch3-8814bd0b796b2e291fa5b4a1033f0313c8a26065.tar.gz | |
Build Catch3 as C++17
C++17 is still the widest common target, and a library built on it stays
usable from C++17 and every later standard, while C++20 would have left
out many users.
Concepts become enable_if on named traits in Detail/TypeTraits.hpp, which
also replaces std::remove_cvref_t and std::identity. std::span becomes
std::vector references, std::bit_cast becomes static_cast and memcpy,
template lambdas become helper templates, and std::erase_if, contains,
starts_with and ends_with have their C++17 forms. Random::Between no
longer uses a lambda over a constexpr local, which MSVC rejects outside
/permissive-, so the headers work under its default mode too.
Tests give up designated initializers, which MSVC refuses in C++17. CI
builds the matrix in C++17 and C++20, since the headers promise both.
Diffstat (limited to 'src/Progmasoft/Catch3/Generators')
| -rw-r--r-- | src/Progmasoft/Catch3/Generators/Element.hpp | 12 | ||||
| -rw-r--r-- | src/Progmasoft/Catch3/Generators/Integer.hpp | 12 | ||||
| -rw-r--r-- | src/Progmasoft/Catch3/Generators/Tuple.hpp | 3 |
3 files changed, 15 insertions, 12 deletions
diff --git a/src/Progmasoft/Catch3/Generators/Element.hpp b/src/Progmasoft/Catch3/Generators/Element.hpp index 087b6355..2c270d18 100644 --- a/src/Progmasoft/Catch3/Generators/Element.hpp +++ b/src/Progmasoft/Catch3/Generators/Element.hpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: MPL-2.0 WITH AdditionRef-Progmasoft-Exception-1.1 #pragma once +#include <Progmasoft/Catch3/Detail/TypeTraits.hpp> #include <Progmasoft/Catch3/Generator.hpp> #include <algorithm> -#include <concepts> #include <cstddef> #include <initializer_list> #include <iterator> @@ -20,8 +20,9 @@ namespace Progmasoft::Catch3 /// The list order is the simplicity order: a value shrinks to the values /// listed before it, earliest first, so place the simplest case first. /// A value that is not in the list has no candidates. - template<typename ValueType> - requires std::equality_comparable<ValueType> + template<typename ValueType, + std::enable_if_t<Detail::kIsEqualityComparable<ValueType>, int> + = 0> [[nodiscard]] Generator<ValueType> Element(std::vector<ValueType> values) { @@ -52,8 +53,9 @@ namespace Progmasoft::Catch3 } /// Convenience overload for a literal list of values. - template<typename ValueType> - requires std::equality_comparable<ValueType> + template<typename ValueType, + std::enable_if_t<Detail::kIsEqualityComparable<ValueType>, int> + = 0> [[nodiscard]] Generator<ValueType> Element(std::initializer_list<ValueType> values) { diff --git a/src/Progmasoft/Catch3/Generators/Integer.hpp b/src/Progmasoft/Catch3/Generators/Integer.hpp index 45192b3d..3659aa4f 100644 --- a/src/Progmasoft/Catch3/Generators/Integer.hpp +++ b/src/Progmasoft/Catch3/Generators/Integer.hpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: MPL-2.0 WITH AdditionRef-Progmasoft-Exception-1.1 #pragma once +#include <Progmasoft/Catch3/Detail/TypeTraits.hpp> #include <Progmasoft/Catch3/Generator.hpp> #include <algorithm> -#include <concepts> #include <limits> #include <type_traits> @@ -13,8 +13,7 @@ namespace Progmasoft::Catch3 namespace Detail { - template<std::integral IntegerType> - requires(!std::same_as<IntegerType, bool>) + template<typename IntegerType, Detail::EnableIfInteger<IntegerType> = 0> [[nodiscard]] std::vector<IntegerType> ShrinkInteger(IntegerType value, IntegerType minimum, @@ -24,7 +23,9 @@ namespace Progmasoft::Catch3 const auto addCandidate = [&](IntegerType candidate) { if (candidate < minimum || candidate > maximum || candidate == value - || std::ranges::find(candidates, candidate) + || std::find(candidates.begin(), + candidates.end(), + candidate) != candidates.end()) { return; @@ -86,8 +87,7 @@ namespace Progmasoft::Catch3 /// Generates integers over the inclusive range and shrinks toward simple /// values. - template<std::integral IntegerType> - requires(!std::same_as<IntegerType, bool>) + template<typename IntegerType, Detail::EnableIfInteger<IntegerType> = 0> [[nodiscard]] Generator<IntegerType> Integer(IntegerType minimum = std::numeric_limits<IntegerType>::lowest(), IntegerType maximum = std::numeric_limits<IntegerType>::max()) diff --git a/src/Progmasoft/Catch3/Generators/Tuple.hpp b/src/Progmasoft/Catch3/Generators/Tuple.hpp index df58da05..3e889307 100644 --- a/src/Progmasoft/Catch3/Generators/Tuple.hpp +++ b/src/Progmasoft/Catch3/Generators/Tuple.hpp @@ -54,10 +54,11 @@ namespace Progmasoft::Catch3 /// runner's greedy restart this minimizes every component without /// trying the cross product of candidates. template<typename... ValueTypes> - requires(sizeof...(ValueTypes) > 0) [[nodiscard]] Generator<std::tuple<ValueTypes...>> Tuple(Generator<ValueTypes>... generators) { + static_assert(sizeof...(ValueTypes) > 0, + "Tuple requires at least one generator"); using Value = std::tuple<ValueTypes...>; const std::tuple<Generator<ValueTypes>...> components{ std::move( generators)... }; |