优化无所事宜的仿函数

时间:2017-11-01 07:20:25

标签: c++11 functor

我可以确定编译器优化不做任何函子吗?

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

我使用仿函数

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

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

someFunction(WithoutTransform<>());

0 个答案:

没有答案