#ifndef TUPLE_OO_HPP_ #define TUPLE_OO_HPP_ #include #include #define TPL_SIZE_(Tuple) std::tuple_size_v> template constexpr auto apply2_impl_(BinOp &&f, Tuple &&lhs, Tuple &&rhs, std::index_sequence) { return std::make_tuple( std::forward(f)(std::get(lhs), std::get(rhs))...); } template constexpr auto apply2(BinOp &&f, Tuple &&lhs, Tuple &&rhs) { return apply2_impl_( f, lhs, rhs, std::make_index_sequence()); } #define OO_TUPLE_EQ_(op) \ template \ constexpr auto operator op(std::tuple const &lhs, \ std::tuple const &rhs) { \ return apply2([](auto &&l, auto &&r) { return l op r; }, lhs, rhs); \ } \ template \ constexpr auto operator oper##=(std::tuple &lhs, \ const std::tuple &rhs) { \ return lhs = lhs oper rhs; \ } OO_TUPLE_EQ_(+) OO_TUPLE_EQ_(-) OO_TUPLE_EQ_(*) OO_TUPLE_EQ_(/) OO_TUPLE_EQ_(%) OO_TUPLE_EQ_(&) OO_TUPLE_EQ_(|) OO_TUPLE_EQ_(^) OO_TUPLE_EQ_(<<) OO_TUPLE_EQ_(>>) #undef OO_TUPLE_EQ_ #undef TPL_SIZE_ #endif