title: C++ function decorator
body: <p>I am looking for a way to decorate functions or lambdas in C++. The goal is to do something before and after the function call. As I've seen the closest thing to use is std::function but it needs to have the types of its arguments.</p>
  
  <pre><code>class FunctionDecorator
  {
  public:
      FunctionDecorator( std::function func )
          : m_func( func )
  
      void operator()()
      {
          // do some stuff prior to function call
  
          m_func();
  
          // do stuff after function call
      }
  
  private:
      std::function m_func;
  };
  </code></pre>
  
  <p>It would be great if by template type could be used in std::function and it could deduce it somehow when i pass pointer to a function or a result from std::bind. 
  Is such thing possible in C++.</p>