mercredi 1 novembre 2017

Optimization of doing nothing functor

Can I be sure that complier optimize doing nothing functor?

template< typename T = vector<short> >
struct WithoutTransform
{
    T operator()(const T &data)
    {
        return data;
    }
};

I use functors for

template<class Transformer>
void someFunction(Transformer tr)
{
    vector<short> data;
    ...
    anotherFunction(tr(data));

}
void anotherFunction(const vector<short> & data){...};

someFunction(WithoutTransform<>());

Aucun commentaire:

Enregistrer un commentaire