Skip to content

Commit 529b25e

Browse files
committed
decrementable uses hidden friend
1 parent 0313cbf commit 529b25e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

include/strong_type/strong_type.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -603,22 +603,23 @@ struct decrementable
603603
class modifier
604604
{
605605
public:
606+
friend
606607
STRONG_CONSTEXPR
607608
T&
608-
operator--()
609+
operator--(T& t)
609610
noexcept(noexcept(--std::declval<T&>().value_of()))
610611
{
611-
auto &self = static_cast<T&>(*this);
612-
--value_of(self);
613-
return self;
612+
--value_of(t);
613+
return t;
614614
}
615615

616+
friend
616617
STRONG_CONSTEXPR
617618
T
618-
operator--(int)
619+
operator--(T& t, int)
619620
{
620-
auto copy = static_cast<T&>(*this);
621-
--*this;
621+
auto copy = t;
622+
--t;
622623
return copy;
623624
}
624625
};

0 commit comments

Comments
 (0)