vendredi 23 novembre 2018

What is the template syntax for an arbitrary container of doubles?

I have a function that rounds a value according to a policy

double round(double f, enum Policy);

What I want to do now is to build a version of this that can be applied only to a container of doubles (there's no point in having a container of any other type due to the way the rounding works).

template <class Iterable>
Iterable<double> round(
    Iterable<double> y,
    enum Policy
){
    for (auto&& e : y){
        e = round(e, type);
    }
    return y;
}

I know my template syntax is not correct, but what should it be?

Aucun commentaire:

Enregistrer un commentaire