SpECTRE
v2021.02.08
Documentation
Introduction
Releases
Installation
User Tutorials
Dev Guide
Code of Conduct
Contributing Guide
Code Reference
Topics
Namespaces
Files
Bibliography
View on GitHub
src
Utilities
TypeTraits
IsIterable.hpp
1
// Distributed under the MIT License.
2
// See LICENSE.txt for details.
3
4
#pragma once
5
6
#include <
type_traits
>
7
8
namespace
tt
{
9
// @{
10
/// \ingroup TypeTraitsGroup
11
/// \brief Check if type T has a begin() and end() function
12
///
13
/// \details
14
/// Given a type `T` inherits from std::true_type if `T` has member functions
15
/// `begin()` and `end()`, otherwise inherits from std::false_type
16
///
17
/// \usage
18
/// For any type `T`
19
/// \code
20
/// using result = tt::is_iterable<T>;
21
/// \endcode
22
///
23
/// \metareturns
24
/// std::bool_constant
25
///
26
/// \semantics
27
/// If `T` has member function `begin()` and `end()` then
28
/// \code
29
/// typename result::type = std::true_type;
30
/// \endcode
31
/// otherwise
32
/// \code
33
/// typename result::type = std::false_type;
34
/// \endcode
35
///
36
/// \example
37
/// \snippet Test_IsIterable.cpp is_iterable_example
38
/// \tparam T the type to check
39
template
<
typename
T,
typename
= std::
void
_t<>>
40
struct
is_iterable
:
std::false_type
{};
41
42
/// \cond HIDDEN_SYMBOLS
43
template
<
typename
T>
44
struct
is_iterable
<T, std::void_t<decltype(std::declval<T>().begin(),
45
std::declval<T>().end())>>
46
:
std::true_type
{};
47
/// \endcond
48
49
/// \see is_iterable
50
template
<
typename
T>
51
constexpr
bool
is_iterable_v
=
is_iterable<T>::value
;
52
53
/// \see is_iterable
54
template
<
typename
T>
55
using
is_iterable_t
=
typename
is_iterable<T>::type
;
56
// @}
57
}
// namespace tt
std::false_type
tt::is_iterable
Check if type T has a begin() and end() function.
Definition:
IsIterable.hpp:40
tt::is_iterable_t
typename is_iterable< T >::type is_iterable_t
Definition:
IsIterable.hpp:55
tt
Definition:
TensorExpression.hpp:141
tt::is_iterable_v
constexpr bool is_iterable_v
Definition:
IsIterable.hpp:51
type_traits
© Copyright 2017 - 2021
SXS Collaboration
,
Distributed under the
MIT License