
On Wed, Mar 26, 2008 at 7:11 AM, <dherring@ll.mit.edu> wrote:
Quick question:
In boost/pool/detail/gcd_lcm.hpp, why does
template <typename Integer> Integer lcm(const Integer & A, const Integer & B);
take its parameters as const references instead of just passing the values?
This avoids unnecessary copying in case existing 'Integer' objects/instances are passed to the function. For example, you can use this to make your own 'Integer-conforming' class and avoid extraneous copies. In case you pass in values, you cause the creation of temporaries -- which the compiler can optimize out later for you. -- Dean Michael C. Berris Software Engineer, Friendster, Inc. [http://blog.cplusplus-soup.com] [mikhailberis@gmail.com] [+63 928 7291459] [+1 408 4049523]