On Mon, Nov 13, 2017 at 9:20 AM, Beman Dawes via Boost
Peter Sommerlad, committee member and C++Now presenter who often proposes additions to fill in holes in the standard library, asked me:
Are you aware of anybody who tried to provide a boost::operators style of automatically providing additional operators with a single base class that through SFINAE injects all possible operators based on the ones defined in the template parameter? This won't give you the control of the current boost::operators, but would be much easier to teach.
For example
struct Me : make_operators_for<Me>{ Me& operator+=(Me const&); // You get + bool operator<(Me const&) const; // You get all relops (<=> will make that obsolete) Me& operator++(); // you get postfix //etc. };
Today we have the facilities and compilers to make that happen.
What do you think? Who should I ask?
Anyone doing any work on operators or have any thoughts about updating boost::operators?
At one point I made a CRTP base that conditionally provides operators,
but only for comparisons (==, !=, <, >, <=, >=). In order to not
negatively impact compilation and to preserve the operators as inline,
non-template friends, I had to make some different design decisions
from Boost.Operators.
First, in order to avoid subtleties, when you inherit from the CRTP
base you specify "dependencies" in addition to the ChildType. These
dependencies, in practice, are a list of all of the other bases and
members of the ChildType that might contribute to equivalence and
ordering. The operators are then conditionally provided by the CRTP
base if and only if any required operators are callable for each
dependency (i.e. == and != are only generated if the following is
valid for each dependency (std::declval