Fix compiling with C++17 + Clang 5 + libstdc++ v5

This basically tests the combination where the compiler supports most
of C++17 but the library does not.
This commit is contained in:
Dimitrij Mijoski 2021-03-26 02:04:45 +01:00 committed by Martin Hořeňovský
parent 023b5306b4
commit 86f86c4c23
4 changed files with 20 additions and 15 deletions

View File

@ -61,6 +61,13 @@ matrix:
packages: ['clang-5.0'] packages: ['clang-5.0']
env: COMPILER='clang++-5.0' CPP14=1 env: COMPILER='clang++-5.0' CPP14=1
- os: linux
compiler: clang
addons:
apt:
sources: *all_sources
packages: ['clang-5.0']
env: COMPILER='clang++-5.0' CPP17=1
- os: linux - os: linux
compiler: clang compiler: clang

View File

@ -222,7 +222,7 @@
// Check if byte is available and usable // Check if byte is available and usable
# if __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER) # if __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER)
# include <cstddef> # include <cstddef>
# if __cpp_lib_byte > 0 # if defined(__cpp_lib_byte) && (__cpp_lib_byte > 0)
# define CATCH_INTERNAL_CONFIG_CPP17_BYTE # define CATCH_INTERNAL_CONFIG_CPP17_BYTE
# endif # endif
# endif // __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER) # endif // __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER)

View File

@ -55,11 +55,11 @@ namespace Matchers {
return arr; return arr;
} }
#ifdef CATCH_CPP17_OR_GREATER #if defined( __cpp_lib_logical_traits ) && __cpp_lib_logical_traits >= 201510
using std::conjunction; using std::conjunction;
#else // CATCH_CPP17_OR_GREATER #else // __cpp_lib_logical_traits
template<typename... Cond> template<typename... Cond>
struct conjunction : std::true_type {}; struct conjunction : std::true_type {};
@ -67,7 +67,7 @@ namespace Matchers {
template<typename Cond, typename... Rest> template<typename Cond, typename... Rest>
struct conjunction<Cond, Rest...> : std::integral_constant<bool, Cond::value && conjunction<Rest...>::value> {}; struct conjunction<Cond, Rest...> : std::integral_constant<bool, Cond::value && conjunction<Rest...>::value> {};
#endif // CATCH_CPP17_OR_GREATER #endif // __cpp_lib_logical_traits
template<typename T> template<typename T>
using is_generic_matcher = std::is_base_of< using is_generic_matcher = std::is_base_of<

View File

@ -62,12 +62,12 @@ TEST_CASE("tables", "[generators]") {
// Structured bindings make the table utility much nicer to use // Structured bindings make the table utility much nicer to use
TEST_CASE( "strlen2", "[approvals][generators]" ) { TEST_CASE( "strlen2", "[approvals][generators]" ) {
auto [test_input, expected] = GENERATE( table<std::string, size_t>({ using tuple_type = std::tuple<std::string, int>; // see above workaround
{"one", 3}, auto [test_input, expected] =
{"two", 3}, GENERATE( table<std::string, size_t>( { tuple_type{ "one", 3 },
{"three", 5}, tuple_type{ "two", 3 },
{"four", 4} tuple_type{ "three", 5 },
})); tuple_type{ "four", 4 } } ) );
REQUIRE( test_input.size() == expected ); REQUIRE( test_input.size() == expected );
} }
@ -103,11 +103,9 @@ TEST_CASE( "strlen3", "[generators]" ) {
static auto eatCucumbers( int start, int eat ) -> int { return start-eat; } static auto eatCucumbers( int start, int eat ) -> int { return start-eat; }
SCENARIO("Eating cucumbers", "[generators][approvals]") { SCENARIO("Eating cucumbers", "[generators][approvals]") {
using tuple_type = std::tuple<int, int, int>;
auto [start, eat, left] = GENERATE( table<int,int,int> ({ auto [start, eat, left] = GENERATE( table<int, int, int>(
{ 12, 5, 7 }, { tuple_type{ 12, 5, 7 }, tuple_type{ 20, 5, 15 } } ) );
{ 20, 5, 15 }
}));
GIVEN( "there are " << start << " cucumbers" ) GIVEN( "there are " << start << " cucumbers" )
WHEN( "I eat " << eat << " cucumbers" ) WHEN( "I eat " << eat << " cucumbers" )