VCCC  2024.05
VisualCamp Common C++ library
type_helper.hpp
Go to the documentation of this file.
1 # /*
2 # * Created by YongGyu Lee on 2020/02/23.
3 # */
4 #
5 # ifndef VCCC_MATH_MATRIX_TYPE_HELPER_HPP
6 # define VCCC_MATH_MATRIX_TYPE_HELPER_HPP
7 #
8 # include <type_traits>
9 #
11 
12 namespace vccc {
13 namespace internal {
14 namespace math {
15 
16 template<typename T>
17 struct hold_type_selector {
18  using type =
19  std::conditional_t<bool(static_cast<int>(traits<T>::option) & static_cast<int>(Flag::kReferenceUnsafe)),
20  const std::remove_reference_t<T>,
21  const T&>;
22  using non_const_type =
23  std::conditional_t<bool(static_cast<int>(traits<T>::option) & static_cast<int>(Flag::kReferenceUnsafe)),
24  std::remove_reference_t<T>,
25  T&>;
26 };
27 
28 template<typename T>
29 using hold_type_selector_t = typename hold_type_selector<T>::type;
30 
31 template<typename T>
32 struct is_alias_safe : std::integral_constant<bool, !(static_cast<int>(traits<T>::option) & static_cast<int>(Flag::kAliasUnsafe))> {};
33 
34 template<typename T> using is_alias_safe_t = typename is_alias_safe<T>::type;
35 
36 
37 template<typename T>
38 struct is_concrete_matrix : std::false_type {};
39 
40 template<typename T, int m, int n>
41 struct is_concrete_matrix<Matrix<T, m, n>> : std::true_type {};
42 
43 template<typename T>
44 using is_concrete_matrix_t = typename is_concrete_matrix<T>::type;
45 
46 template<typename TL, typename TR>
47 struct is_same_size_impl
48  : std::integral_constant<bool, ((static_cast<int>(TL::rows) == static_cast<int>(TR::rows)) && (static_cast<int>(TL::cols) == static_cast<int>(TR::cols)))> {};
49 
50 template<typename A, typename B>
51 struct is_same_size : is_same_size_impl<traits<A>, traits<B>> {};
52 
53 template<typename TL, typename TR>
54 struct is_same_type_impl : std::is_same<typename TL::value_type, typename TR::value_type> {};
55 
56 template<typename A, typename B>
57 struct is_same_type : is_same_type_impl<traits<A>, traits<B>> {};
58 
59 } // namespace math
60 } // namespace internal
61 } // namespace vccc
62 
63 
64 # endif // VCCC_MATH_MATRIX_TYPE_HELPER_HPP
Definition: directory.h:12