Is call to function object inlined?
- by dehmann
In the following code, Foo::add calls a function via a function object:
struct Plus {
  inline int operator()(int x, int y) const {
    return x + y;
  }
};
template<class Fct>
struct Foo {
  Fct fct;
  Foo(Fct f) : fct(f) {}
  inline int add(int x, int y) {
    return fct(x,y); // same efficiency adding directly?
  }  
};
Is this the same efficiency as calling x+y directly in Foo::add? In other words, does the compiler typically directly replace fct(x,y) with the actual call, inlining the code, when compiling with optimizations enabled?