DxLibEx
basic_types.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_HPP_
9 #define DXLE_INC_BASIC_TYPES_HPP_
14 namespace dxle {
15 
16  //operators betwin point_c and size_c
17 
29  template <typename T1, typename T2, enable_if_t<is_representable<T2, T1>::value, nullptr_t> = nullptr>
30  point_c<T1>& operator +=(point_c<T1>& l, const size_c<T2>& r) DXLE_NOEXCEPT_IF_EXPR(l.x += r.width)
31  {
32  l.x += r.width;
33  l.y += r.height;
34  return l;
35  }
36 
48  template <typename T1, typename T2, enable_if_t<is_representable<T2, T1>::value, nullptr_t> = nullptr>
49  size_c<T1>& operator +=(size_c<T1>& l, const point_c<T2>& r) DXLE_NOEXCEPT_IF_EXPR(l.width += r.x)
50  {
51  l.width += r.x;
52  l.height += r.y;
53  return l;
54  }
55 
67  template <typename T1, typename T2, enable_if_t<is_representable<T2, T1>::value, nullptr_t> = nullptr>
68  point_c<T1>& operator -=(point_c<T1>& l, const size_c<T2>& r) DXLE_NOEXCEPT_IF_EXPR(l.x -= r.width)
69  {
70  l.x -= r.width;
71  l.y -= r.height;
72  return l;
73  }
74 
86  template <typename T1, typename T2, enable_if_t<is_representable<T2, T1>::value, nullptr_t> = nullptr>
87  size_c<T1>& operator -=(size_c<T1>& l, const point_c<T2>& r) DXLE_NOEXCEPT_IF_EXPR(l.width -= r.x)
88  {
89  l.width -= r.x;
90  l.height -= r.y;
91  return l;
92  }
93 
105  template <typename T1, typename T2>
106  DXLE_CONSTEXPR auto operator +(const point_c<T1>& l, const size_c<T2>& r) DXLE_NOEXCEPT_IF_EXPR(l.x + r.width)
107  -> point_c<decltype(std::declval<std::remove_cv_t<T1>>() + std::declval<std::remove_cv_t<T2>>())>
108  {
109  return {l.x + r.width, l.y + r.height};
110  }
111 
123  template <typename T1, typename T2>
124  DXLE_CONSTEXPR auto operator +(const size_c<T1>& l, const point_c<T2>& r) DXLE_NOEXCEPT_IF_EXPR(l.width + r.x)
125  -> size_c<decltype(std::declval<std::remove_cv_t<T1>>() + std::declval<std::remove_cv_t<T2>>())>
126  {
127  return {l.width + r.x, l.height + r.y};
128  }
129 
141  template <typename T1, typename T2>
142  DXLE_CONSTEXPR auto operator -(const point_c<T1>& l, const size_c<T2>& r) DXLE_NOEXCEPT_IF_EXPR(l.x - r.width)
143  -> point_c<decltype(std::declval<std::remove_cv_t<T1>>() - std::declval<std::remove_cv_t<T2>>())>
144  {
145  return {l.x - r.width, l.y - r.height};
146  }
147 
159  template <typename T1, typename T2>
160  DXLE_CONSTEXPR auto operator -(const size_c<T1>& l, const point_c<T2>& r) DXLE_NOEXCEPT_IF_EXPR(l.width - r.x)
161  -> size_c<decltype(std::declval<std::remove_cv_t<T1>>() - std::declval<std::remove_cv_t<T2>>())>
162  {
163  return {l.width - r.x, l.height - r.y};
164  }
165 }
166 #endif
Template class for 2D sizes specified by its coordinates width and height.
Definition: point2d.hpp:36
point_c< T1 > T2 DXLE_CONSTEXPR auto operator+(const point_c< T1 > &l, const point_c< T2 > &r) DXLE_NOEXCEPT_IF_EXPR(l.x+r.x) -> point_c< decltype(std::declval< std::remove_cv_t< T1 >>()+std::declval< std::remove_cv_t< T2 >>())>
Definition: point2d.hpp:373
#define DXLE_CONSTEXPR
Definition: suffix.hpp:21
Definition: cast_if.hpp:12
value_type width
Definition: size.hpp:104
#define DXLE_NOEXCEPT_IF_EXPR(EXPR)
Definition: suffix.hpp:110
value_type x
Definition: point2d.hpp:109
Template class for 2D points specified by its coordinates x and y.
Definition: point2d.hpp:105
DXLE_CONSTEXPR counter_iterator< T > operator-(typename counter_iterator< T >::difference_type n, const counter_iterator< T > &it) DXLE_NOEXCEPT_OR_NOTHROW