Skip to content

Commit d334e87

Browse files
committed
Add mixed compound operators
1 parent e4bc095 commit d334e87

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

include/boost/decimal/decimal32_fast.hpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,23 @@ class decimal32_fast final
255255
constexpr auto operator/=(decimal32_fast rhs) noexcept -> decimal32_fast&;
256256
constexpr auto operator%=(decimal32_fast rhs) noexcept -> decimal32_fast&;
257257

258+
// Mixed type compound operators
259+
template <typename Integer>
260+
constexpr auto operator+=(Integer rhs) noexcept
261+
BOOST_DECIMAL_REQUIRES_RETURN(detail::is_integral_v, Integer, decimal32_fast&);
262+
263+
template <typename Integer>
264+
constexpr auto operator-=(Integer rhs) noexcept
265+
BOOST_DECIMAL_REQUIRES_RETURN(detail::is_integral_v, Integer, decimal32_fast&);
266+
267+
template <typename Integer>
268+
constexpr auto operator*=(Integer rhs) noexcept
269+
BOOST_DECIMAL_REQUIRES_RETURN(detail::is_integral_v, Integer, decimal32_fast&);
270+
271+
template <typename Integer>
272+
constexpr auto operator/=(Integer rhs) noexcept
273+
BOOST_DECIMAL_REQUIRES_RETURN(detail::is_integral_v, Integer, decimal32_fast&);
274+
258275
// Increment and decrement
259276
constexpr auto operator++() noexcept -> decimal32_fast&;
260277
constexpr auto operator++(int) noexcept -> decimal32_fast&;
@@ -1108,6 +1125,38 @@ constexpr auto decimal32_fast::operator/=(decimal32_fast rhs) noexcept -> decima
11081125
return *this;
11091126
}
11101127

1128+
template <typename Integer>
1129+
constexpr auto decimal32_fast::operator+=(Integer rhs) noexcept
1130+
BOOST_DECIMAL_REQUIRES_RETURN(detail::is_integral_v, Integer, decimal32_fast&)
1131+
{
1132+
*this = *this + rhs;
1133+
return *this;
1134+
}
1135+
1136+
template <typename Integer>
1137+
constexpr auto decimal32_fast::operator-=(Integer rhs) noexcept
1138+
BOOST_DECIMAL_REQUIRES_RETURN(detail::is_integral_v, Integer, decimal32_fast&)
1139+
{
1140+
*this = *this - rhs;
1141+
return *this;
1142+
}
1143+
1144+
template <typename Integer>
1145+
constexpr auto decimal32_fast::operator*=(Integer rhs) noexcept
1146+
BOOST_DECIMAL_REQUIRES_RETURN(detail::is_integral_v, Integer, decimal32_fast&)
1147+
{
1148+
*this = *this * rhs;
1149+
return *this;
1150+
}
1151+
1152+
template <typename Integer>
1153+
constexpr auto decimal32_fast::operator/=(Integer rhs) noexcept
1154+
BOOST_DECIMAL_REQUIRES_RETURN(detail::is_integral_v, Integer, decimal32_fast&)
1155+
{
1156+
*this = *this / rhs;
1157+
return *this;
1158+
}
1159+
11111160
constexpr auto decimal32_fast::operator++() noexcept -> decimal32_fast&
11121161
{
11131162
constexpr decimal32_fast one(1, 0);

0 commit comments

Comments
 (0)