DxLibEx
distance_result_type_t.hpp
Go to the documentation of this file.
1 /*=============================================================================
2  Copyright (C) 2015-2017 DxLibEx project
3  https://github.com/Nagarei/DxLibEx/
4 
5  Distributed under the Boost Software License, Version 1.0.
6  (See http://www.boost.org/LICENSE_1_0.txt)
7 =============================================================================*/
8 #ifndef DXLE_INC_BASIC_TYPES_DISTANCE_RESULT_TYPE_T_HPP_
9 #define DXLE_INC_BASIC_TYPES_DISTANCE_RESULT_TYPE_T_HPP_
12 namespace dxle {
13  namespace detail{
14  template<typename T, bool is_integral = std::is_integral<T>::value, bool is_float = std::is_floating_point<T>::value>
16  template<typename T>
17  struct distance_result_type_impl<T, false, true> {
18  typedef T type;
19  };
20  template<typename T>
21  struct distance_result_type_impl<T, true, false> {
22  typedef double type;//If any argument has integral type, it is cast to double.
23  };
24  }
25  template<typename T1, typename T2> struct distance_result_type : dxle::detail::distance_result_type_impl<decltype(std::declval<std::remove_cv_t<T1>>() - std::declval<std::remove_cv_t<T2>>())> {};
26  template<typename T1, typename T2>
28 }
29 #endif //DXLE_INC_BASIC_TYPES_DISTANCE_RESULT_TYPE_T_HPP_
Definition: cast_if.hpp:12
typename distance_result_type< T1, T2 >::type distance_result_type_t