Opened 10 years ago
Last modified 9 years ago
#7145 new Bugs
rational.hpp - Avoid repeated construction
| Reported by: | 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.
  Note:
 See   TracTickets
 for help on using tickets.
    
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 templatedusingcan be used for template-based parameters?)Maybe I should go the other way; use
int_typefor member function definitions, andIntTypeonly within non-member functions.