
On 10/6/07, Phil Endecott <spam_from_boost_dev@chezphil.org> wrote:
I haven't been following this thread, but my radar spotted this:
Now operator<<() is used instead of c'tors, this has three advantages:
Hmmm, someone else is tempted to invent yet another use for operator<< ?
If we keep doing this, we'll end up with entire functions where everything is done using << and there are no alphabetic identifiers at all! In this case, compare
f << &foo2 << foo4 << foo3 << &foo1 << foo5;
with
f.add_overload(&foo2); f.add_overload(foo4); f.add_overload(foo3); f.add_overload(&foo1); f.add_overload(foo5);
The first version involves less typing. But, to someone who did not write the code, wouldn't it be reasonable to look at it and think that f is a file and that the various foos are being written to it?
The second version involves more typing. But it tells you exactly what it's doing. Surely it is better.
The important update of this version of overload.hpp is that indices are avoided and the order of registering the overload functions can be random, i.e. has not to follow the order of declaration of the signatures that the overload class supports. Choosing add_overload(), operator<<() or something else is just a taste matter IMHO. Using operator<<() would be nice, but if this can create confusion it can be changed to something else 'Surely better'. Marco