IsA.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` is a template specialization of `U`
12 ///
13 /// \requires `U` is a class template
14 /// \effects If `T` is a template specialization of `U`, then inherits from
15 /// std::true_type, otherwise inherits from std::false_type
16 ///
17 /// \usage
18 /// For any type `T` and class template `U`
19 /// \code
20 /// using result = tt::is_a<U, T>;
21 /// \endcode
22 /// \metareturns
23 /// std::bool_constant
24 ///
25 /// \semantics
26 /// If the type `T` is a template specialization of the type `U`, then
27 /// \code
28 /// typename result::type = std::true_type;
29 /// \endcode
30 /// otherwise
31 /// \code
32 /// typename result::type = std::false_type;
33 /// \endcode
34 ///
35 /// \example
36 /// \snippet Test_IsA.cpp is_a_example
37 /// \see is_std_array
38 /// \tparam T type to check
39 /// \tparam U the type that T might be a template specialization of
40 template <template <typename...> class U, typename T>
41 struct is_a : std::false_type {};
42 
43 /// \cond HIDDEN_SYMBOLS
44 template <template <typename...> class U, typename... Args>
45 struct is_a<U, U<Args...>> : std::true_type {};
46 /// \endcond
47 
48 /// \see is_a
49 template <template <typename...> class U, typename... Args>
50 constexpr bool is_a_v = is_a<U, Args...>::value;
51 
52 /// \see is_a
53 template <template <typename...> class U, typename... Args>
54 using is_a_t = typename is_a<U, Args...>::type;
55 // @}
56 
57 } // namespace tt
tt::is_a_t
typename is_a< U, Args... >::type is_a_t
Definition: IsA.hpp:54
tt::is_a
Check if type T is a template specialization of U
Definition: IsA.hpp:41
std::false_type
tt::is_a_v
constexpr bool is_a_v
Definition: IsA.hpp:50
tt
Definition: TensorExpression.hpp:121
type_traits