ENH: add is_range test to pTraits

- helps support algorithms with list-based forwarding
This commit is contained in:
Gregor Weiss
2023-07-07 14:06:14 +02:00
committed by Mark Olesen
parent 1e2858e8cb
commit a6744d0814

View File

@ -41,6 +41,7 @@ Description
#include "direction.H"
#include <type_traits> // For std::integral_constant, std::void_t (C++17)
#include <utility> // For declval
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -163,6 +164,31 @@ struct pTraits_has_zero
{};
/*---------------------------------------------------------------------------*\
Container Traits
\*---------------------------------------------------------------------------*/
//- Test for containers with begin/end range iterators.
template<class T, class = void>
struct is_range : std::false_type {};
//- Test for list containers with begin/end range iterators.
//- \attention May yield a false positive with HashTable, HashSet etc
template<class T>
struct is_range
<
T,
stdFoam::void_t
<
decltype(std::declval<T>().begin()),
decltype(std::declval<T>().end())
>
>
:
std::true_type
{};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam