GetFundamentalType.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <type_traits>
7 
8 #include "Utilities/NoSuchType.hpp"
9 #include "Utilities/TMPL.hpp"
10 #include "Utilities/TypeTraits.hpp"
11 
12 namespace tt {
13 // @{
14 /// \ingroup TypeTraitsGroup
15 /// \brief Extracts the fundamental type for a container
16 ///
17 /// \details Designates a type alias `get_fundamental_type::type`
18 /// as `T` when `T` itself is an appropriate fundamental type, and the
19 /// contained type of a container which specifies a `value_type`.
20 ///
21 /// `get_fundamental_type_t<T>` is provided as a type alias to
22 /// `type` from `get_fundamental_type<T>`
23 ///
24 /// \snippet Test_GetFundamentalType.cpp get_fundamental_type
25 template <typename T, typename Enable = cpp17::void_t<>>
27  using type = tmpl::conditional_t<cpp17::is_fundamental_v<T>, T, NoSuchType>;
28 };
29 
30 /// \cond
31 template <typename T>
32 struct get_fundamental_type<T, cpp17::void_t<typename T::value_type>> {
33  using type = typename get_fundamental_type<typename T::value_type>::type;
34 };
35 /// \endcond
36 
37 template <typename T>
38 using get_fundamental_type_t = typename get_fundamental_type<T>::type;
39 // @}
40 } // namespace tt
Extracts the fundamental type for a container.
Definition: GetFundamentalType.hpp:26
void void_t
Given a set of types, returns void
Definition: TypeTraits.hpp:187
A collection of useful type traits.
Definition: TensorExpression.hpp:113
Used to mark "no type" or "bad state" for metaprogramming.
Definition: NoSuchType.hpp:10
Wraps the template metaprogramming library used (brigand)