Opened 10 years ago

Last modified 9 years ago

#7145 new Bugs

rational.hpp - Avoid repeated construction

Reported by: Dan Searles <dansearles@…> Owned by: Jonathan Turkanis
Milestone: To Be Determined Component: rational
Version: Boost 1.51.0 Severity: Problem
Keywords: Cc:

Description

In rational.hpp, two times 'IntType zero(0);' is used to "Avoid repeated construction" and two times 'int_type const zero( 0 );' is used. The two without the const may not be avoiding repeated construction. Since int_type is just a typedef from IntType, it might be clearer if all int_type were replaced with IntType and the typedef for int_type removed.

Change History (1)

comment:1 by Daryle Walker, 9 years ago

When a class template's instantiation is hidden behind a typedef/type-alias, its template parameters are a pain to get. That's why it's customary for template classes to provide means to get its parameters within themselves. That means member type-aliases for type-based parameters and constants or static member functions for value-based parameters. (Maybe the new C++11 templated using can be used for template-based parameters?)

Maybe I should go the other way; use int_type for member function definitions, and IntType only within non-member functions.

Note: See TracTickets for help on using tickets.