mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Fix compilation failure when using libstdc++10 (#1929)
The issue is caused by deleted `std::__detail::begin` declared in `bits/iterator_concepts.h`. This would be found by ADL, and because it is deleted, compilation would fail. This change makes it so that we SFINAE on `begin(std::declval<T>())` and `end(std::declval<T>())` being well-formed.
This commit is contained in:
parent
c24f7e5b34
commit
8b5f6e26d3
@ -446,20 +446,27 @@ namespace Catch {
|
|||||||
#endif // CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER
|
#endif // CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
struct not_this_one {}; // Tag type for detecting which begin/ end are being selected
|
// Import begin/ end from std here
|
||||||
|
|
||||||
// Import begin/ end from std here so they are considered alongside the fallback (...) overloads in this namespace
|
|
||||||
using std::begin;
|
using std::begin;
|
||||||
using std::end;
|
using std::end;
|
||||||
|
|
||||||
not_this_one begin( ... );
|
namespace detail {
|
||||||
not_this_one end( ... );
|
template <typename...>
|
||||||
|
struct void_type {
|
||||||
|
using type = void;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, typename = void>
|
||||||
|
struct is_range_impl : std::false_type {
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct is_range {
|
struct is_range_impl<T, typename void_type<decltype(begin(std::declval<T>()))>::type> : std::true_type {
|
||||||
static const bool value =
|
};
|
||||||
!std::is_same<decltype(begin(std::declval<T>())), not_this_one>::value &&
|
} // namespace detail
|
||||||
!std::is_same<decltype(end(std::declval<T>())), not_this_one>::value;
|
|
||||||
|
template <typename T>
|
||||||
|
struct is_range : detail::is_range_impl<T> {
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(_MANAGED) // Managed types are never ranges
|
#if defined(_MANAGED) // Managed types are never ranges
|
||||||
|
Loading…
Reference in New Issue
Block a user