On Apr 15, 4:25 am, Michael Aaron Safyan <michaelsaf...@[EMAIL PROTECTED]
>
wrote:
> Using operator% in this manner would never pass my code review, because
> this usage has absolutely nothing to do with taking the modulus of a
> value, and -- therefore -- this usage is unintuitive.
Reserving the % operator for the modulus operation seems a waste of a
good operator among a sparse selection. In an application close to 100
thousand lines of C++ code I can count on one hand the number of times
% is used for modulus (5 out of 761 hits on '%', some of which are in
comments).
Knowledge about operator plus type is required to understand any C++
code. That's the nature of overloading. You may have noticed that I
included the use of Boost Format in my example. It also makes good use
of the % operator (and the operator choice is not arbitrary).
> For the second example, functions should throw exceptions, by default.
My usage example made use of the Win32 DeleteFile function. Sometimes
you need to deal with C or C++ libraries that use error codes. In
these cases it is very convenient to tag all the calls with E%
"operators" to ensure that no error code will go untested. I'm sure
untested error codes is a major issue throughout the C/C++ programming
world, not just in my code. E% makes it as little hassle as possible
to add the tests.
Regards,
Vidar Hasfjord
--
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


|