VCCC  2024.05
VisualCamp Common C++ library
lossless_type_int_division.hpp
Go to the documentation of this file.
1 # /*
2 # * Created by YongGyu Lee on 2020/12/08.
3 # */
4 #
5 # ifndef VCCC_TYPE_TRAITS_DETAIL_LOSSLESS_TYPE_INT_DIVISION_HPP
6 # define VCCC_TYPE_TRAITS_DETAIL_LOSSLESS_TYPE_INT_DIVISION_HPP
7 #
8 # include <type_traits>
9 # include <algorithm>
10 
11 namespace vccc {
12 
13 namespace internal {
14 
15 // left for specialization
16 template<typename...> struct lossless_type_int_division;
17 
18 template<typename T1, typename T2>
19 struct lossless_type_int_division<T1, T2> {
20  using type = std::conditional_t<(sizeof(T1) > sizeof(T2) ? sizeof(T1) : sizeof(T2)) <= 4, float, double>;
21 };
22 
23 template<typename T1, typename T2>
24 using lossless_type_int_division_t = typename lossless_type_int_division<T1, T2>::type;
25 
26 } // namespace internal
27 
28 } // namespace vccc
29 
30 # endif // VCCC_TYPE_TRAITS_DETAIL_LOSSLESS_TYPE_INT_DIVISION_HPP
Definition: directory.h:12