From: Daryle Walker (dwalker07_at_[hidden])
Date: 2003-07-30 23:51:00


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