Skip to content

Commit

Permalink
Use explicit types for pcp::units function arguments
Browse files Browse the repository at this point in the history
Templating the type was overkill, given that the `PMDA_PMUNITS` macro
only exists to automatically order the arguments correctly for the
`pmUnits` member of the `pmDesc` structure (the order reverses on some
platforms). But also, the templating was forcing all parameters to be
the same type, whereas the `pmUnits` structure members are not all the
same type.

Given that `pmUnits` has not changed in 8 years, it makes most sense to
replace the templating with the explicit `pmUnits` types directly.
  • Loading branch information
pcolby committed Oct 14, 2017
1 parent b5a1f1f commit f495c3a
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions include/pcp-cpp/units.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,16 @@ class instance_domain;
* This allows C++11-style initialisation lists, while avoiding C++ "extended
* initializer lists" warnings.
*
* @param a The first argument to pass to the PMDA_PMUNITS macro.
* @param b The second argument to pass to the PMDA_PMUNITS macro.
* @param c The third argument to pass to the PMDA_PMUNITS macro.
* @param d The fourth argument to pass to the PMDA_PMUNITS macro.
* @param e The fifth argument to pass to the PMDA_PMUNITS macro.
* @param f The sixth argument to pass to the PMDA_PMUNITS macro.
* @param a The first argument to pass to the PMDA_PMUNITS macro (dimTime).
* @param b The second argument to pass to the PMDA_PMUNITS macro (dimSpace).
* @param c The third argument to pass to the PMDA_PMUNITS macro (dimCount).
* @param d The fourth argument to pass to the PMDA_PMUNITS macro (scaleSpace).
* @param e The fifth argument to pass to the PMDA_PMUNITS macro (scaleTime).
* @param f The sixth argument to pass to the PMDA_PMUNITS macro (scaleCount).
*
* @return A pmUnits value constructed from the supplied arguments.
*/
template<typename Type>
inline pmUnits units(Type a, Type b, Type c, Type d, Type e, Type f)
inline pmUnits units(int a, int b, int c, unsigned d, unsigned e, int f)
{
const pmUnits units = PMDA_PMUNITS(a,b,c,d,e,f);
return units;
Expand Down

0 comments on commit f495c3a

Please sign in to comment.