Practical difference between a struct with only operator() and a normal function
问题 I have seen code that looks like this: struct foo_functor { template <typename T, typename U> constexpr auto operator()(T t, U u) const -> decltype(t | u) { return t | u; } }; constexpr foo_functor foo; As far as I can tell, it's the same as the following: template <typename T, typename U> constexpr auto foo(T t, U u) -> decltype(t | u) { return t | u; } Why would you want to do the first one? Are there any differences? As far as I could see from the compiler output, at least with constexpr ,