In <boost/operators.hpp> we have helper classes that can generate "operator OP" from "operator OP=", where "OP" can be "+", "/", ">>", etc. What about types and algorithms where the non-assignment version is easier than the assignment version? Should we have reverse helpers?

//================================================================
template < std::size_t N >
        class bitsetint;

template < std::size_t M, std::size_t N >
        bitsetint<static_max<M,N>::value + 1>
          operator +( bitsetint<M>, bitsetint<N> );

template < std::size_t M, std::size_t N >
        bitsetint<M * N>
          operator *( bitsetint<M>, bitsetint<N> );
//================================================================

This is an example where the non-assignment versions of the operations can give a more-complete answer than having to shoehorn the results into a variable like the first operand. The assignment versions should call the code given here (to later chop off the most significant bits) to save work and enforce consistency.

Daryle

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to