8 #ifndef DXLE_INC_BASIC_TYPES_SIZE_HPP_ 9 #define DXLE_INC_BASIC_TYPES_SIZE_HPP_ 24 #include <type_traits> 31 template<typename T, enable_if_t<std::is_nothrow_move_constructible<T>::value && std::is_nothrow_move_assignable<T>::value, nullptr_t>>
99 template<typename T, enable_if_t<std::is_nothrow_move_constructible<T>::value && std::is_nothrow_move_assignable<T>::value, nullptr_t> =
nullptr>
112 : width(static_cast<value_type>(other.width)), height(static_cast<value_type>(other.height)) {}
116 : width(static_cast<value_type>(
std::move(other.width))), height(static_cast<value_type>(
std::move(other.height))) {}
125 : width(static_cast<value_type>(other.x)), height(static_cast<value_type>(other.y)) {}
129 : width(static_cast<value_type>(
std::move(other.x))), height(static_cast<value_type>(
std::move(other.y))) {}
133 : width(other.x), height(other.y) {}
137 : width(
std::move(other.x)), height(
std::move(other.y)) {}
142 this->width = r.width;
143 this->height = r.height;
149 this->width = std::move(r.width);
150 this->height = std::move(r.height);
166 return{
static_cast<Tp2_
>(this->
width), static_cast<Tp2_>(this->height) };
172 return std::pair<Tp2_, Tp2_>(
static_cast<Tp2_
>(this->
width), static_cast<Tp2_>(this->height));
201 return size_c<T>(std::move(pa.first), std::move(pa.second));
206 template<
typename CharType,
typename Size_cType>
210 os << static_cast<use_big_type_when_one_byte_p>(s.width) << str << static_cast<use_big_type_when_one_byte_p>(s.height);
212 template<
typename CharType,
typename Size_cType>
217 is.ignore((std::numeric_limits<std::streamsize>::max)(), dxle::char_constant::comma<CharType>());
219 s.width =
static_cast<Size_cType
>(
width); s.height =
static_cast<Size_cType
>(
height);
233 template<
typename T> std::ostream& operator<<(std::ostream& os, const size_c<T>& s)
235 dxle::detail::ostream_operator_helper<char, T>(os,
", ", s);
249 template<
typename T> std::wostream& operator<<(std::wostream& os, const size_c<T>& s)
251 dxle::detail::ostream_operator_helper<wchar_t, T>(os, L
", ", s);
267 dxle::detail::istream_operator_helper<char, T>(is, s);
283 dxle::detail::istream_operator_helper<wchar_t, T>(is, s);
296 template <
typename T>
299 return { -r.width, -r.height };
311 template <
typename T>
323 template <
typename T>
337 template <typename T1, typename T2, enable_if_t<is_representable<T2, T1>::value, nullptr_t> =
nullptr>
341 l.height += r.height;
356 template <typename T1, typename T2, enable_if_t<is_representable<T2, T1>::value, nullptr_t> =
nullptr>
360 l.height -= r.height;
375 template <
typename T1,
typename T2>
377 ->size_c<decltype(std::declval<std::remove_cv_t<T1>>() + std::declval<std::remove_cv_t<T2>>())>
379 return {l.width + r.width, l.height + r.height};
393 template <
typename T1,
typename T2>
395 ->size_c<decltype(std::declval<std::remove_cv_t<T1>>() - std::declval<std::remove_cv_t<T2>>())>
397 return {l.width - r.width, l.height - r.height};
411 template <
typename T1,
typename T2>
413 ->size_c<decltype(std::declval<std::remove_cv_t<T1>>() * std::declval<std::remove_cv_t<T2>>())>
415 return {l.width * r, l.height * r};
429 template <
typename T1,
typename T2>
431 ->size_c<decltype(std::declval<std::remove_cv_t<T1>>() * std::declval<std::remove_cv_t<T2>>())>
433 return {l * r.width, l * r.height};
447 template <typename T1, typename T2, enable_if_t<is_representable<T2, T1>::value, nullptr_t> =
nullptr>
466 template <
typename T1,
typename T2>
468 ->size_c<decltype(std::declval<std::remove_cv_t<T1>>() / std::declval<std::remove_cv_t<T2>>())>
470 return {l.width / r, l.height / r};
484 template <typename T1, typename T2, enable_if_t<is_representable<T2, T1>::value, nullptr_t> =
nullptr>
503 template <
typename T>
506 return (l.width != r.width) || (l.height != r.height);
520 template <
typename T>
536 template <
typename T>
539 return static_cast<bool>(s);
554 template <
typename T>
557 return static_cast<bool>(s);
572 template <
typename T>
575 return !
static_cast<bool>(s);
590 template <
typename T>
593 return !
static_cast<bool>(s);
622 #define DXLE_TEMP_make_hash(int_t, bit, bit2)\ 623 template <> struct hash<dxle::size_c<int_t##bit##_t>> {\ 625 hash(const hash&) = default;\ 626 hash(hash&& other) :hash_run(std::move(other.hash_run)) {}\ 628 hash& operator=(const hash& other) { hash_run = other.hash_run; return *this; }\ 629 hash& operator=(hash&& other) { hash_run = std::move(other.hash_run); return *this; }\ 630 size_t operator()(const dxle::size_c<int_t##bit##_t>& key) const { return hash_run((static_cast<int_t##_fast##bit2##_t>(key.width) << bit) | static_cast<int_t##_fast##bit2##_t>(key.height)); }\ 632 std::hash<int_t##_fast##bit2##_t> hash_run;\ 642 #undef DXLE_TEMP_make_hash 645 #endif //DXLE_INC_BASIC_TYPES_SIZE_HPP_ Template class for 2D sizes specified by its coordinates width and height.
DXLE_CONSTEXPR size_c< T > operator-(const size_c< T > &r) DXLE_NOEXCEPT_IF_EXPR(-r.width)
Overload of unary operator -.
DXLE_CONSTEXPR size_c(const point_c< value_type, nullptr > &other) DXLE_NOEXCEPT_IF((dxle
DXLE_CONSTEXPR size_c(point_c< Tp2_, nullptr > &&other) DXLE_NOEXCEPT_IF((dxle
size_c< std::size_t > size
void istream_operator_helper(std::basic_istream< CharType > &is, size_c< Size_cType > &s)
#define DXLE_TEMP_make_hash(int_t, bit, bit2)
size_c< T1 > & operator/=(size_c< T1 > &l, T2 r) DXLE_NOEXCEPT_IF_EXPR(l.width/
Overload of binary operator /=.
DXLE_CONSTEXPR size_c(size_c< value_type > &&o) DXLE_NOEXCEPT_OR_NOTHROW
DXLE_CONSTEXPR int abs(int j) DXLE_NOEXCEPT_OR_NOTHROW
DXLE_CONSTEXPR bool operator_bool_helper(const T &first, const T &second) DXLE_NOEXCEPT_IF_EXPR(dxle
point_c< T1 > T2 DXLE_CONSTEXPR auto operator/(const point_c< T1 > &l, T2 r) DXLE_NOEXCEPT_IF_EXPR(l.x/r) -> point_c< decltype(std::declval< std::remove_cv_t< T1 >>()/std::declval< std::remove_cv_t< T2 >>())>
typename use_big_type_when_one_byte< T >::type use_big_type_when_one_byte_t
for int8_t/uint8_t
std::wistream & operator>>(std::wistream &is, size_c< T > &s)
istream operator
DXLE_CONSTEXPR auto operator*(const size_c< T1 > &l, T2 r) DXLE_NOEXCEPT_IF_EXPR(l.width *r) -> size_c< decltype(std::declval< std::remove_cv_t< T1 >>() *std::declval< std::remove_cv_t< T2 >>())>
Overload of binary operator *.
DXLE_CONSTEXPR size_c(point_c< value_type, nullptr > &&other) DXLE_NOEXCEPT_IF((dxle
DXLE_CONSTEXPR size_c(size_c< Tp2_ > &&other) DXLE_NOEXCEPT_IF((dxle
DXLE_CONSTEXPR size_c< T > operator+(const size_c< T > &r) DXLE_NOEXCEPT_IF(std
Overload of unary operator +.
size_c< T1 > & operator+=(size_c< T1 > &l, const size_c< T2 > &r) DXLE_NOEXCEPT_IF_EXPR(l.width+
Overload of binary operator +=.
size_c & operator=(const size_c< value_type > &r) DXLE_NOEXCEPT_IF((std
DXLE_CONSTEXPR size_c(const point_c< Tp2_, nullptr > &other) DXLE_NOEXCEPT_IF((dxle
DXLE_CONSTEXPR size_c(value_type &&width_, value_type &&height_) DXLE_NOEXCEPT_OR_NOTHROW
#define DXLE_NOEXCEPT_IF_EXPR(EXPR)
DXLE_CONSTEXPR size_c() DXLE_NOEXCEPT_IF((std
DXLE_CONSTEXPR size_c(const size_c< Tp2_ > &other) DXLE_NOEXCEPT_IF((dxle
size_c & operator=(size_c< value_type > &&r) DXLE_NOEXCEPT_OR_NOTHROW
size_c< T > make_size_c(std::pair< T, T > &&pa) DXLE_NOEXCEPT_OR_NOTHROW
conversion from std::pair
#define DXLE_NOEXCEPT_IF(COND)
size_c< T > make_size_c(const std::pair< T, T > &pa) DXLE_NOEXCEPT_IF(std
conversion from std::pair
#define DXLE_NOEXCEPT_OR_NOTHROW
DXLE_CONSTEXPR size_c(const value_type &width_, const value_type &height_) DXLE_NOEXCEPT_IF((std
Template class for 2D points specified by its coordinates x and y.
std::istream & operator>>(std::istream &is, size_c< T > &s)
istream operator
DXLE_CONSTEXPR size_c(const size_c< value_type > &o) DXLE_NOEXCEPT_IF((std
void ostream_operator_helper(std::basic_ostream< CharType > &os, const CharType *str, const size_c< Size_cType > &s)
size_c< unsigned int > sizeui
size_c< T1 > & operator*=(size_c< T1 > &l, T2 r) DXLE_NOEXCEPT_IF_EXPR(l.width *
Overload of binary operator *=.