For an empty object, just create it on the stack. Adding a functor to your type as a member will make all your objects larger. Adding it as a base (to use empty base optimization) will lead to a weird design in which your type implements operator()(const MyData&) for no reason. Even if you make it private, the operator will be there.
Since the type has no members, there is no problem with the locality of the cache, since there is no data to access. The main use of the stateless functor is to allow the compiler to embed a function call (compared to a free function of the same name)
David RodrΓguez - dribeas
source share