mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add is_range test to pTraits
- helps support algorithms with list-based forwarding
This commit is contained in:
committed by
Mark Olesen
parent
1e2858e8cb
commit
a6744d0814
@ -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
|
||||
|
||||
Reference in New Issue
Block a user