DxLibEx
safe_dist.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_ALGORITHM_SAFE_DIST_HPP_
9 #define DXLE_INC_ALGORITHM_SAFE_DIST_HPP_
10 #include "dxlibex/config/defines.h"
12 namespace dxle {
13  template<typename T1, typename T2>
14  DXLE_CONSTEXPR auto safe_dist(const T1& n1, const T2& n2) DXLE_NOEXCEPT_IF_EXPR((n1 - n2)) -> decltype(n1 - n2)
15  {
16  return (n1 < n2) ? n2 - n1 : n1 - n2;
17  }
18 }
19 #endif //DXLE_INC_ALGORITHM_SAFE_DIST_HPP_
#define DXLE_CONSTEXPR
Definition: suffix.hpp:21
point_c< T1 > T2
Definition: point2d.hpp:353
Definition: cast_if.hpp:12
#define DXLE_NOEXCEPT_IF_EXPR(EXPR)
Definition: suffix.hpp:110
DXLE_CONSTEXPR auto safe_dist(const T1 &n1, const T2 &n2) DXLE_NOEXCEPT_IF_EXPR((n1 - n2)) -> decltype(n1 - n2)
Definition: safe_dist.hpp:14