So,
I have the following template that multiplies two unit, e.g. velocity and time.
//! The product of the TWO units
template<template<typename> typename QuantityLhs, template<typename> typename QuantityRhs>
struct Multiply
{
template<typename T>
using type = units::unit<typename product_t<QuantityLhs<UNIT_LIB_DEFAULT_TYPE>, QuantityRhs<UNIT_LIB_DEFAULT_TYPE>>::conversion_factor, T>;
};
This is called for example in the following way:
using AccuType = Multiply<Velocity, Time>::type<float>;
Issue
The above definition only accepts two template arguments, but I want an arbitrary number of them.
So what I wish to be able to write is something like
using AccuType = Multiply<Velocity, Time, Temperature, Density>::type<float>;
So my idea is to create a variadic template
//! The product of the ANY number of units
template<typename... Quantities>
struct MultiplyMany
{
// Code
};
Unfortunately, I don’t know how to make it work. I have this idea that MultiplyMany
would just somehow use a for loop or something to call the basic Multiply
struct.
Is that even possible?