From 268565f27dee903f62cbcc030ba0e1160f7d1649 Mon Sep 17 00:00:00 2001 From: yumetodo Date: Fri, 26 Feb 2016 21:06:30 +0900 Subject: [PATCH] =?UTF-8?q?#46=20size=5Fc,=20point3d=5Fc=E3=81=8Cstd::is?= =?UTF-8?q?=5Farithmetic::value=3D=3D=3Dtrue=E3=82=92=E8=A6=81=E6=B1=82?= =?UTF-8?q?=E3=81=97=E3=81=A6=E3=81=84=E3=81=9F=E3=81=AE=E3=82=92=E3=82=84?= =?UTF-8?q?=E3=82=81=E3=81=9F=20arithmetic=5Ft=E3=82=92=E5=89=8A=E9=99=A4?= =?UTF-8?q?=E3=80=81use=5Fbig=5Ftype=5Fwhen=5Fone=5Fbyte=5Ft=E3=81=AE?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=20=E5=85=A8=E4=BD=93=E7=9A=84=E3=81=AA?= =?UTF-8?q?=E5=BE=AE=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectDxLibEx.vcxproj | 2 +- ProjectDxLibEx.vcxproj.filters | 2 +- dxlibex/basic_types/point2d.hpp | 36 +++++----- dxlibex/basic_types/point3d.hpp | 71 ++++++++++++------- dxlibex/basic_types/size.hpp | 62 +++++++++------- ...t.hpp => use_big_type_when_one_byte_t.hpp} | 23 ++++-- 6 files changed, 121 insertions(+), 75 deletions(-) rename dxlibex/basic_types/{arithmetic_t.hpp => use_big_type_when_one_byte_t.hpp} (52%) diff --git a/ProjectDxLibEx.vcxproj b/ProjectDxLibEx.vcxproj index b680011..f1beb9f 100644 --- a/ProjectDxLibEx.vcxproj +++ b/ProjectDxLibEx.vcxproj @@ -18,7 +18,7 @@ - + diff --git a/ProjectDxLibEx.vcxproj.filters b/ProjectDxLibEx.vcxproj.filters index 65d81d3..e66d8e7 100644 --- a/ProjectDxLibEx.vcxproj.filters +++ b/ProjectDxLibEx.vcxproj.filters @@ -92,7 +92,7 @@ dxlibex - + dxlibex\basic_types diff --git a/dxlibex/basic_types/point2d.hpp b/dxlibex/basic_types/point2d.hpp index ab5fa67..e83d8a0 100644 --- a/dxlibex/basic_types/point2d.hpp +++ b/dxlibex/basic_types/point2d.hpp @@ -13,7 +13,7 @@ #include "dxlibex/type_traits/is_representable.hpp" #include "dxlibex/type_traits/is_nothrow.hpp" #include "dxlibex/type_traits/ignore.hpp" -#include "dxlibex/basic_types/arithmetic_t.hpp" +#include "dxlibex/basic_types/use_big_type_when_one_byte_t.hpp" #include "dxlibex/basic_types/stdint.hpp" #include "dxlibex/basic_types/distance_result_type_t.hpp" #include "dxlibex/basic_types/coordinate_operator_bool_helper.hpp" @@ -32,7 +32,7 @@ #include "dxlibex/config/defines.h" namespace dxle { - template::value && std::is_nothrow_move_constructible::value && std::is_nothrow_move_assignable::value, nullptr_t>> + template::value && std::is_nothrow_move_assignable::value, nullptr_t>> class size_c; /** \~japanese @brief 2次元座標(x, y) テンプレートクラス。 @@ -107,7 +107,7 @@ namespace dxle { public: typedef typename std::remove_cv::type value_type; value_type x, y; - DXLE_CONSTEXPR_CLASS point_c() DXLE_NOEXCEPT_IF(std::is_nothrow_constructible::value) : x(), y() {} + DXLE_CONSTEXPR_CLASS point_c() DXLE_NOEXCEPT_IF((std::is_nothrow_constructible::value)) : x(), y() {} DXLE_CONSTEXPR_CLASS point_c(const value_type& x_, const value_type& y_) DXLE_NOEXCEPT_IF((std::is_nothrow_copy_constructible::value)) : x(x_), y(y_) {} DXLE_CONSTEXPR_CLASS point_c(value_type&& x_, value_type&& y_) DXLE_NOEXCEPT_OR_NOTHROW : x(std::move(x_)), y(std::move(y_)) {} @@ -162,27 +162,27 @@ namespace dxle { @relates point_c \~japanese @brief std::pairからの変換 \~english @brief conversion from std::pair - \~japanese @param p std::pairオブジェクトへのconst-lvalue reference - \~english @param p const-lvalue reference to std::pair + \~japanese @param pa std::pairオブジェクトへのconst-lvalue reference + \~english @param pa const-lvalue reference to std::pair \~japanese @return point_cクラスオブジェクト \~english @return point_c value */ - template point_c make_point_c(const std::pair& p) DXLE_NOEXCEPT_IF(std::is_nothrow_copy_constructible::value) + template point_c make_point_c(const std::pair& pa) DXLE_NOEXCEPT_IF(std::is_nothrow_copy_constructible::value) { - return point_c(p.first, p.second); + return point_c(pa.first, pa.second); } /** @relates point_c \~japanese @brief std::pairからの変換 \~english @brief conversion from std::pair - \~japanese @param p std::pairオブジェクトへのrvalue reference - \~english @param p rvalue reference to std::pair + \~japanese @param pa std::pairオブジェクトへのrvalue reference + \~english @param pa rvalue reference to std::pair \~japanese @return point_cクラスオブジェクト \~english @return point_c value */ - template point_c make_point_c(std::pair&& p) DXLE_NOEXCEPT_OR_NOTHROW + template point_c make_point_c(std::pair&& pa) DXLE_NOEXCEPT_OR_NOTHROW { - return point_c(std::move(p.first), std::move(p.second)); + return point_c(std::move(pa.first), std::move(pa.second)); } //ostream operator @@ -190,13 +190,13 @@ namespace dxle { template void ostream_operator_helper(std::basic_ostream& os, const CharType* str, const point_c& p) { - using arithmetic_p = arithmetic_t; - os << static_cast(p.x) << str << static_cast(p.y); + using use_big_type_when_one_byte_p = use_big_type_when_one_byte_t; + os << static_cast(p.x) << str << static_cast(p.y); } template void istream_operator_helper(std::basic_istream& is, point_c& p) { - arithmetic_t x, y; + use_big_type_when_one_byte_t x, y; is >> x; is.ignore((std::numeric_limits::max)(), ','); is >> y; @@ -232,7 +232,7 @@ namespace dxle { */ template std::wostream& operator<<(std::wostream& os, const point_c& p) { - detail::ostream_operator_helper(os, L", ", p); + dxle::detail::ostream_operator_helper(os, L", ", p); return os; } /** @@ -264,7 +264,7 @@ namespace dxle { */ template std::wistream& operator>>(std::wistream& is, point_c& p) { - detail::istream_operator_helper(is, p); + dxle::detail::istream_operator_helper(is, s); return is; } @@ -554,7 +554,7 @@ namespace dxle { @endcode */ template - DXLE_CONSTEXPR_CLASS bool operator ==(const point_c& p, std::nullptr_t) DXLE_NOEXCEPT_IF_EXPR(static_cast(p)) + DXLE_CONSTEXPR_CLASS bool operator ==(const point_c& p, nullptr_t) DXLE_NOEXCEPT_IF_EXPR(static_cast(p)) { return !static_cast(p); } @@ -572,7 +572,7 @@ namespace dxle { @endcode */ template - DXLE_CONSTEXPR_CLASS bool operator ==(std::nullptr_t, const point_c& p) DXLE_NOEXCEPT_IF_EXPR(static_cast(p)) + DXLE_CONSTEXPR_CLASS bool operator ==(nullptr_t, const point_c& p) DXLE_NOEXCEPT_IF_EXPR(static_cast(p)) { return !static_cast(p); } diff --git a/dxlibex/basic_types/point3d.hpp b/dxlibex/basic_types/point3d.hpp index 1160dae..c75d5d0 100644 --- a/dxlibex/basic_types/point3d.hpp +++ b/dxlibex/basic_types/point3d.hpp @@ -11,7 +11,7 @@ #include "dxlibex/type_traits/first_enabled.hpp" #include "dxlibex/type_traits/enable_if.hpp" #include "dxlibex/type_traits/is_representable.hpp" -#include "dxlibex/basic_types/arithmetic_t.hpp" +#include "dxlibex/basic_types/use_big_type_when_one_byte_t.hpp" #include "dxlibex/basic_types/stdint.hpp" #include "dxlibex/basic_types/distance_result_type_t.hpp" #include "dxlibex/basic_types/coordinate_operator_bool_helper.hpp" @@ -68,8 +68,32 @@ namespace dxle { dxle::point3di pt = (a + b)*10.f; std::cout << pt << std::endl; @endcode + \~english @tparam T + \~english T is the type of the elements. T must meet the requirements of NothrowMoveAssignable and NothrowConstructable. + \~english T is expected the following conditions to use all features. + \~english - DefaultConstructible + \~english - CopyConstructible + \~english - CopyAssignable + \~english - has unary operator + - + \~english - has binary operator + - * / += -= *= /= == != + \~english - has binary operator != to compare with 0 + \~english - able to call functon abs and hypot. + \~english - std::is_floating_point == true or able to convert to double via static_cast. + \~japanese @tparam T + \~japanese 型Tは少なくとも以下の条件を満たしている必要があります。 + \~japanese - 型が例外を投げずにムーブ構築可能であること(is_nothrow_move_constructible::value == trueであること) + \~japanese - 型が例外を投げずにムーブ代入可能であること(is_nothrow_move_assignable::value == trueであること) + \~japanese . + \~japanese また、以下の条件を満たしている事が期待されています。 + \~japanese - 型がデフォルト構築可能であること(is_default_constructible::value == trueであること) + \~japanese - 型がコピー構築可能であること(is_copy_constructible::value == trueであること) + \~japanese - 型がコピー代入可能であること(is_copy_assignable::value == trueであること) + \~japanese - 単項 + - 演算子を持つこと + \~japanese - 二項 + - * / += -= *= /= == != 演算子を持つこと + \~japanese - 0と!=で比較することが可能であること( t != 0; (tはconst T&型の変数)がコンパイル可能であること) + \~japanese - abs, hypot関数がADLなどで見つかること */ - template::value && std::is_move_constructible::value, nullptr_t> = nullptr> + template::value && std::is_nothrow_move_assignable::value, nullptr_t> = nullptr> class point3d_c final { public: @@ -80,11 +104,11 @@ namespace dxle { DXLE_CONSTEXPR_CLASS point3d_c(value_type&& x_, value_type&& y_, value_type&& z_) DXLE_NOEXCEPT_OR_NOTHROW : x(std::move(x_)), y(std::move(y_)), z(std::move(z_)) {} //copy constructor - DXLE_CONSTEXPR_CLASS point3d_c(const point3d_c& o) DXLE_NOEXCEPT_IF(std::is_nothrow_copy_constructible::value) : x(o.x), y(o.y), z(o.z) {} + DXLE_CONSTEXPR_CLASS point3d_c(const point3d_c& o) DXLE_NOEXCEPT_IF((std::is_nothrow_copy_constructible::value)) : x(o.x), y(o.y), z(o.z) {} //move constructor DXLE_CONSTEXPR_CLASS point3d_c(point3d_c&& o) DXLE_NOEXCEPT_OR_NOTHROW : x(std::move(o.x)), y(std::move(o.y)), z(std::move(o.z)) {} //copy assignment operator - point3d_c& operator=(const point3d_c& r) DXLE_NOEXCEPT_IF(std::is_nothrow_copy_assignable::value) + point3d_c& operator=(const point3d_c& r) DXLE_NOEXCEPT_IF((std::is_nothrow_copy_assignable::value)) { this->x = r.x; this->y = r.y; @@ -99,7 +123,6 @@ namespace dxle { this->z = std::move(r.z); return *this; } - //!operator bool //!1. operator bool //!2. operator != (nullptr) @@ -154,13 +177,13 @@ namespace dxle { template void ostream_operator_helper(std::basic_ostream& os, const CharType* str, const point3d_c& p) { - using arithmetic_p = arithmetic_t; - os << static_cast(p.x) << str << static_cast(p.y) << str << static_cast(p.z); + using use_big_type_when_one_byte_p = use_big_type_when_one_byte_t; + os << static_cast(p.x) << str << static_cast(p.y) << str << static_cast(p.z); } template void istream_operator_helper(std::basic_istream& is, point3d_c& p) { - arithmetic_t x, y, z; + use_big_type_when_one_byte_t x, y, z; is >> x; is.ignore((std::numeric_limits::max)(), ','); is >> y; @@ -360,7 +383,7 @@ namespace dxle { \~japanese @return point3d_cクラスオブジェクトの各メンバーに第二引数を乗じた結果 \~english @return Memberwise multiplication by 2nd argument */ - template ::value, nullptr_t> = nullptr> + template DXLE_CONSTEXPR_CLASS auto operator *(const point3d_c& l, T2 r) DXLE_NOEXCEPT_IF_EXPR(l.x * r) ->point3d_c>() * std::declval>())> { @@ -378,7 +401,7 @@ namespace dxle { \~japanese @return point3d_cクラスオブジェクトの各メンバーに第一引数を乗じた結果 \~english @return Memberwise multiplication by 1st argument */ - template ::value, nullptr_t> = nullptr> + template DXLE_CONSTEXPR_CLASS auto operator *(T1 l, const point3d_c& r) DXLE_NOEXCEPT_IF_EXPR(l + r.x) ->point3d_c>() * std::declval>())> { @@ -396,7 +419,7 @@ namespace dxle { \~japanese @return 第一引数へのlvalue reference \~english @return lvalue reference to 1st argument */ - template ::value && is_representable::value, nullptr_t> = nullptr> + template ::value, nullptr_t> = nullptr> point3d_c& operator *=(point3d_c& l, T2 r) DXLE_NOEXCEPT_IF_EXPR(l.x *= r) { l.x *= r; @@ -416,7 +439,7 @@ namespace dxle { \~japanese @return point3d_cクラスオブジェクトの各メンバーを第一引数で割った結果 \~english @return Memberwise multiplication by 1st argument */ - template ::value, nullptr_t> = nullptr> + template DXLE_CONSTEXPR_CLASS auto operator /(const point3d_c& l, T2 r) DXLE_NOEXCEPT_IF_EXPR(l.x / r) ->point3d_c>() - std::declval>())> { @@ -434,7 +457,7 @@ namespace dxle { \~japanese @return 第一引数へのlvalue reference \~english @return lvalue reference to 1st argument */ - template ::value && is_representable::value, nullptr_t> = nullptr> + template ::value, nullptr_t> = nullptr> point3d_c& operator /=(point3d_c& l, T2 r) DXLE_NOEXCEPT_IF_EXPR(l.x /= r) { l.x /= r; @@ -454,7 +477,7 @@ namespace dxle { \~japanese @return 左辺と右辺が等しくなければtrueを返す \~english @return true if left operand is not equal to right operand */ - template ::value, nullptr_t> = nullptr> + template DXLE_CONSTEXPR_CLASS bool operator !=(const point3d_c& l, const point3d_c& r) DXLE_NOEXCEPT_IF_EXPR(l.x != r.x) { return (l.x != r.x) || (l.y != r.y) || (l.z != r.z); @@ -473,7 +496,7 @@ namespace dxle { bool re = p != 0;//false @endcode */ - template ::value, nullptr_t> = nullptr> + template DXLE_CONSTEXPR_CLASS bool operator !=(const point3d_c& p, nullptr_t) DXLE_NOEXCEPT_IF_EXPR(static_cast(p)) { return !static_cast(p); @@ -492,7 +515,7 @@ namespace dxle { bool re = 0 != p;//false @endcode */ - template ::value, nullptr_t> = nullptr> + template DXLE_CONSTEXPR_CLASS bool operator !=(nullptr_t, const point3d_c& p) DXLE_NOEXCEPT_IF_EXPR(static_cast(p)) { return !static_cast(p); @@ -525,10 +548,10 @@ namespace dxle { bool re = 0 == p;//true @endcode */ - template ::value, nullptr_t> = nullptr> + template DXLE_CONSTEXPR_CLASS bool operator ==(const point3d_c& p, nullptr_t) DXLE_NOEXCEPT_IF_EXPR(static_cast(p)) { - return static_cast(p); + return !static_cast(p); } /** @@ -544,7 +567,7 @@ namespace dxle { bool re = 0 == p;//true @endcode */ - template ::value, nullptr_t> = nullptr> + template DXLE_CONSTEXPR_CLASS bool operator ==(nullptr_t, const point3d_c& p) DXLE_NOEXCEPT_IF_EXPR(static_cast(p)) { return static_cast(p); @@ -563,7 +586,7 @@ namespace dxle { const auto result = dxle::abs(p1);//(2, 4) @endcode */ - template::value, nullptr_t> = nullptr> + template DXLE_CONSTEXPR_CLASS point3d_c abs(const point3d_c& o) DXLE_NOEXCEPT_IF_EXPR(abs(o.x)) { return{ abs(o.x), abs(o.y), abs(o.z) }; } /** @@ -577,7 +600,7 @@ namespace dxle { \~japanese @return 計算結果。戻り値の型は暗黙の型変換で得られるものです。 \~english @return Computed result. return value's type is a result of Implicit conversions. */ - template::value && std::is_arithmetic::value, nullptr_t> = nullptr> + template DXLE_CONSTEXPR_CLASS auto dot(const point3d_c& p1, const point3d_c& p2) DXLE_NOEXCEPT_IF_EXPR(p1.x * p2.x + p1.y * p2.y + p1.z * p2.z) -> decltype(std::declval>() * std::declval>()) { @@ -595,7 +618,7 @@ namespace dxle { \~japanese @return 計算結果。 \~english @return Computed result. */ - template::value && std::is_arithmetic::value, nullptr_t> = nullptr> + template DXLE_CONSTEXPR_CLASS auto cross(const point3d_c& p1, const point3d_c& p2) DXLE_NOEXCEPT_IF_EXPR(std::declval() * std::declval() - std::declval() * std::declval()) ->point3d_c>() * std::declval>())> { @@ -616,9 +639,9 @@ namespace dxle { */ template distance_result_type_t distance(const point3d_c& p1, const point3d_c& p2) - DXLE_NOEXCEPT_IF_EXPR(std::hypot(safe_dist(std::declval(), std::declval()), safe_dist(std::declval(), std::declval()))) + DXLE_NOEXCEPT_IF_EXPR(hypot(safe_dist(std::declval(), std::declval()), safe_dist(std::declval(), std::declval()))) { - return std::hypot(safe_dist(p1.x, p2.x), std::hypot(safe_dist(p1.y, p2.y), safe_dist(p1.z, p2.z))); + return hypot(safe_dist(p1.x, p2.x), (safe_dist(p1.y, p2.y), safe_dist(p1.z, p2.z))); } typedef point3d_c point3di; typedef point3d_c point3du8i; diff --git a/dxlibex/basic_types/size.hpp b/dxlibex/basic_types/size.hpp index bc073d4..8751fa9 100644 --- a/dxlibex/basic_types/size.hpp +++ b/dxlibex/basic_types/size.hpp @@ -12,7 +12,7 @@ #include "dxlibex/type_traits/enable_if.hpp" #include "dxlibex/type_traits/is_representable.hpp" #include "dxlibex/type_traits/is_nothrow.hpp" -#include "dxlibex/basic_types/arithmetic_t.hpp" +#include "dxlibex/basic_types/use_big_type_when_one_byte_t.hpp" #include "dxlibex/basic_types/stdint.hpp" #include "dxlibex/basic_types/coordinate_operator_bool_helper.hpp" #include "dxlibex/math.hpp" @@ -70,20 +70,32 @@ namespace dxle { dxle::sizei pt = (a + b)*10.f; std::cout << pt << std::endl; @endcode - \~japanese 型Tは少なくとも以下の条件を満たしている必要があります。 - \~japanese ・std::is_arithmetic::value == trueであること - \~japanese ・型が例外を投げずにムーブ構築可能であること(is_nothrow_move_constructible::value == trueであること) - \~japanese ・型が例外を投げずにムーブ代入可能であること(is_nothrow_move_assignable::value == trueであること) - \~japanese また、以下の条件を満たしている事が期待されています。 - \~japanese ・型がデフォルト構築可能であること(is_default_constructible::value == trueであること) - \~japanese ・型がコピー構築可能であること(is_copy_constructible::value == trueであること) - \~japanese ・型がコピー代入可能であること(is_copy_assignable::value == trueであること) - \~japanese ・0と!=で比較することが可能であること( t != 0; (tはconst T&型の変数)がコンパイル可能であること) - \~japanese ・単項 + - 演算子を持つこと - \~japanese ・二項 + - * / += -= *= /= == != 演算子を持つこと + \~english @tparam T + \~english T is the type of the elements. T must meet the requirements of NothrowMoveAssignable and NothrowConstructable. + \~english T is expected the following conditions to use all features. + \~english - DefaultConstructible + \~english - CopyConstructible + \~english - CopyAssignable + \~english - has unary operator + - + \~english - has binary operator + - * / += -= *= /= == != + \~english - has binary operator != to compare with 0 + \~english - able to call functon abs. + \~japanese @tparam T + \~japanese 型Tは少なくとも以下の条件を満たしている必要があります。 + \~japanese - 型が例外を投げずにムーブ構築可能であること(is_nothrow_move_constructible::value == trueであること) + \~japanese - 型が例外を投げずにムーブ代入可能であること(is_nothrow_move_assignable::value == trueであること) + \~japanese . + \~japanese また、以下の条件を満たしている事が期待されています。 + \~japanese - 型がデフォルト構築可能であること(is_default_constructible::value == trueであること) + \~japanese - 型がコピー構築可能であること(is_copy_constructible::value == trueであること) + \~japanese - 型がコピー代入可能であること(is_copy_assignable::value == trueであること) + \~japanese - 単項 + - 演算子を持つこと + \~japanese - 二項 + - * / += -= *= /= == != 演算子を持つこと + \~japanese - 0と!=で比較することが可能であること( t != 0; (tはconst T&型の変数)がコンパイル可能であること) + \~japanese - abs関数がADLなどで見つかること \~ */ - template::value && std::is_nothrow_move_constructible::value && std::is_nothrow_move_assignable::value, nullptr_t> = nullptr> + template::value && std::is_nothrow_move_assignable::value, nullptr_t> = nullptr> class size_c final { public: @@ -172,13 +184,13 @@ namespace dxle { template void ostream_operator_helper(std::basic_ostream& os, const CharType* str, const size_c& s) { - using arithmetic_p = arithmetic_t; - os << static_cast(s.width) << str << static_cast(s.height); + using use_big_type_when_one_byte_p = use_big_type_when_one_byte_t; + os << static_cast(s.width) << str << static_cast(s.height); } template void istream_operator_helper(std::basic_istream& is, size_c& s) { - arithmetic_t width, height; + use_big_type_when_one_byte_t width, height; is >> width; is.ignore((std::numeric_limits::max)(), ','); is >> height; @@ -374,7 +386,7 @@ namespace dxle { \~japanese @return size_cクラスオブジェクトの各メンバーに第二引数を乗じた結果 \~english @return Memberwise multiplication by 2nd argument */ - template ::value, nullptr_t> = nullptr> + template DXLE_CONSTEXPR_CLASS auto operator *(const size_c& l, T2 r) DXLE_NOEXCEPT_IF_EXPR(l.width * r) ->size_c>() * std::declval>())> { @@ -392,7 +404,7 @@ namespace dxle { \~japanese @return size_cクラスオブジェクトの各メンバーに第一引数を乗じた結果 \~english @return Memberwise multiplication by 1st argument */ - template ::value, nullptr_t> = nullptr> + template DXLE_CONSTEXPR_CLASS auto operator *(T1 l, const size_c& r) DXLE_NOEXCEPT_IF_EXPR(l * r.width) ->size_c>() * std::declval>())> { @@ -410,7 +422,7 @@ namespace dxle { \~japanese @return 第一引数へのlvalue reference \~english @return lvalue reference to 1st argument */ - template ::value && is_representable::value, nullptr_t> = nullptr> + template ::value, nullptr_t> = nullptr> size_c& operator *=(size_c& l, T2 r) DXLE_NOEXCEPT_IF_EXPR(l.width *= r) { l.width *= r; @@ -429,7 +441,7 @@ namespace dxle { \~japanese @return size_cクラスオブジェクトの各メンバーを第一引数で割った結果 \~english @return Memberwise multiplication by 1st argument */ - template ::value, nullptr_t> = nullptr> + template DXLE_CONSTEXPR_CLASS auto operator /(const size_c& l, T2 r) DXLE_NOEXCEPT_IF_EXPR(l.width / r) ->size_c>() / std::declval>())> { @@ -447,7 +459,7 @@ namespace dxle { \~japanese @return 第一引数へのlvalue reference \~english @return lvalue reference to 1st argument */ - template ::value && is_representable::value, nullptr_t> = nullptr> + template ::value, nullptr_t> = nullptr> size_c& operator /=(size_c& l, T2 r) DXLE_NOEXCEPT_IF_EXPR(l.width /= r) { l.width /= r; @@ -466,7 +478,7 @@ namespace dxle { \~japanese @return 左辺と右辺が等しくなければtrueを返す \~english @return true if left operand is not equal to right operand */ - template ::value, nullptr_t> = nullptr> + template DXLE_CONSTEXPR_CLASS bool operator !=(const size_c& l, const size_c& r) DXLE_NOEXCEPT_IF_EXPR(l.width != r.width) { return (l.width != r.width) || (l.height != r.height); @@ -483,7 +495,7 @@ namespace dxle { \~japanese @return 左辺と右辺が等しければtrueを返す \~english @return true if left operand is equal to right operand */ - template ::value, nullptr_t> = nullptr> + template DXLE_CONSTEXPR_CLASS bool operator ==(const size_c& l, const size_c& r) DXLE_NOEXCEPT_IF_EXPR(l != r) { return !(l != r); } /** @@ -536,7 +548,7 @@ namespace dxle { @endcode */ template - DXLE_CONSTEXPR_CLASS bool operator ==(const size_c& s, std::nullptr_t) DXLE_NOEXCEPT_IF_EXPR(static_cast(s)) + DXLE_CONSTEXPR_CLASS bool operator ==(const size_c& s, nullptr_t) DXLE_NOEXCEPT_IF_EXPR(static_cast(s)) { return !static_cast(s); } @@ -554,7 +566,7 @@ namespace dxle { @endcode */ template - DXLE_CONSTEXPR_CLASS bool operator ==(std::nullptr_t, const size_c& s) DXLE_NOEXCEPT_IF_EXPR(static_cast(s)) + DXLE_CONSTEXPR_CLASS bool operator ==(nullptr_t, const size_c& s) DXLE_NOEXCEPT_IF_EXPR(static_cast(s)) { return !static_cast(s); } diff --git a/dxlibex/basic_types/arithmetic_t.hpp b/dxlibex/basic_types/use_big_type_when_one_byte_t.hpp similarity index 52% rename from dxlibex/basic_types/arithmetic_t.hpp rename to dxlibex/basic_types/use_big_type_when_one_byte_t.hpp index ca7e87d..afafcab 100644 --- a/dxlibex/basic_types/arithmetic_t.hpp +++ b/dxlibex/basic_types/use_big_type_when_one_byte_t.hpp @@ -10,12 +10,23 @@ #include "dxlibex/type_traits/first_enabled.hpp" #include "dxlibex/type_traits/enable_if.hpp" namespace dxle { + namespace detail { + template + struct use_big_type_when_one_byte_impl { + using type = T; + }; + template + struct use_big_type_when_one_byte_impl : first_enabled< + enable_if<1 != sizeof(T), T>, + enable_if::value, int>, + unsigned int + > + {}; + } + template + struct use_big_type_when_one_byte : dxle::detail::use_big_type_when_one_byte_impl::value> {}; //! for int8_t/uint8_t - template::value, std::nullptr_t> = nullptr> - using arithmetic_t = first_enabled_t < - enable_if<1 != sizeof(T), T>, - enable_if::value, int>, - unsigned int - >; + template + using use_big_type_when_one_byte_t = typename use_big_type_when_one_byte::type; } #endif //DXLE_INC_BASIC_TYPES_ARTHMETIC_T_HPP_