Jonathan Turkanis wrote:
Daniel Krügler wrote:
Hello,
After a short view at the rational.hpp header I propose to perform the following changes:
There will be at least one major change in boost.Rational soon, at which time I'll probably make a few small changes, including addint a safe bool conversion and cleaning up i/o.
That sounds fine.
2) The function template
template <typename IntType> IntType lcm(IntType n, IntType m);
should be defined as
template <typename IntType> IntType lcm(IntType n, boost::call_traits<IntType>::param_type m);
which makes sense in this case because m is not modified internally (in contrast to n)
I think lcm should be symmetrical.
1) Wow, not so much of details of reasonings, please ;-)) 2) OK, the request of symmetry can lead to several conclusions: If we argue that the interface should not reflect the implementation, the most reasonable signature would be something like template <typename IntType> IntType lcm(const IntTyp& n, const IntTyp& m); (We cannot use the optimal version template <typename IntType> IntType lcm(boost::call_traits<IntType>::param_type n, boost::call_traits<IntType>::param_type m); because that would prevent argument deduction) Otherway around we could argue, that we want to use advantages of a special copy-optimization technique. This is an implementation-driven interface, but there are cases, where proposers (I am not one) have argued that the advantages outweight its disadvantages. If I try to compare these to approaches not too strongly subjectively (its impossible, I know, but I'll try ;-))), than I would say, that an implementation-driven interface should be only used where necessary, but not otherwise. This lead to my proposal to use call-by-value only for the first, not for the second argument of lcm. I don't understand, **why** you think, that the interface must/should be symmetric: 1) Thinking not implementation-driven, than template <typename IntType> IntType lcm(const IntTyp& n, const IntTyp& m); would be right thing for general IntTypes (see std::max/min interface). I would agree to that proposal 2) Thinking implementation-driven, than template <typename IntType> IntType lcm(IntType n, boost::call_traits<IntType>::param_type m); must be acceptable and **even more reasonable** than the currently existing template <typename IntType> IntType lcm(IntType n, boost::call_traits<IntType>::param_type m); interface. Greetings, Daniel