Skip to content

Commit

Permalink
Delete ForbidsComposingWith mixin (#227)
Browse files Browse the repository at this point in the history
It causes problems with Apple Clang version 9, apparently.  I think this
compiler technically falls outside of our support window.  However, an
actual user is having issues with it, and I think `ForbidsComposingWith`
is adding only very marginal value anyway.  I tried deleting it and the
error messages became a couple of lines shorter, although perhaps less
direct (no more reference to "explicitly deleted").

Amusingly, I'm keeping the unit test for it around, because it's one of
those unfortunate "uncomment to test" deals, and the tests _will_ still
pass.  (We'll get compiler errors for doing unsupported operations.)

Fixes #226.
  • Loading branch information
chiphogg committed Mar 11, 2024
1 parent 492e5bd commit ffea274
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 29 deletions.
2 changes: 0 additions & 2 deletions au/constant.hh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ struct Constant : detail::MakesQuantityFromNumber<Constant, Unit>,
detail::ComposesWith<Constant, Unit, Constant, Constant>,
detail::ComposesWith<Constant, Unit, QuantityMaker, QuantityMaker>,
detail::ComposesWith<Constant, Unit, SingularNameFor, SingularNameFor>,
detail::ForbidsComposingWith<Constant, Unit, QuantityPointMaker>,
detail::ForbidsComposingWith<Constant, Unit, QuantityPoint>,
detail::CanScaleByMagnitude<Constant, Unit> {
// Convert this constant to a Quantity of the given rep.
template <typename T>
Expand Down
25 changes: 0 additions & 25 deletions au/wrapper_operations.hh
Original file line number Diff line number Diff line change
Expand Up @@ -217,30 +217,5 @@ struct CanScaleByMagnitude {
}
};

//
// A mixin to explicitly delete operations that we want to forbid.
//
template <template <typename U> class UnitWrapper,
typename Unit,
template <typename... Us>
class OtherWrapper>
struct ForbidsComposingWith {
// (W * O), for wrapper W and wrapper O.
template <typename... Us>
friend constexpr void operator*(UnitWrapper<Unit>, OtherWrapper<Us...>) = delete;

// (W / O), for wrapper W and wrapper O.
template <typename... Us>
friend constexpr void operator/(UnitWrapper<Unit>, OtherWrapper<Us...>) = delete;

// (O * W), for wrapper W and wrapper O.
template <typename... Us>
friend constexpr void operator*(OtherWrapper<Us...>, UnitWrapper<Unit>) = delete;

// (O / W), for wrapper W and wrapper O.
template <typename... Us>
friend constexpr void operator/(OtherWrapper<Us...>, UnitWrapper<Unit>) = delete;
};

} // namespace detail
} // namespace au
2 changes: 0 additions & 2 deletions au/wrapper_operations_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ struct UnitWrapper : MakesQuantityFromNumber<UnitWrapper, Unit>,
ScalesQuantity<UnitWrapper, Unit>,
ComposesWith<UnitWrapper, Unit, UnitWrapper, UnitWrapper>,
ComposesWith<UnitWrapper, Unit, QuantityMaker, QuantityMaker>,
ForbidsComposingWith<UnitWrapper, Unit, QuantityPointMaker>,
ForbidsComposingWith<UnitWrapper, Unit, QuantityPoint>,
CanScaleByMagnitude<UnitWrapper, Unit> {};

TEST(MakesQuantityFromNumber, MakesQuantityWhenPostMultiplyingNumericValue) {
Expand Down

0 comments on commit ffea274

Please sign in to comment.