Jak połączyć std :: bind (), szablony variadic i doskonałe przekazywanie?

Chcę wywołać metodę z innej, za pomocą funkcji innej firmy; ale oba używają różnych szablonów. Na przykład:

void third_party(int n, std::function<void(int)> f)
{
  f(n);
}

struct foo
{
  template <typename... Args>
  void invoke(int n, Args&&... args)
  {
    auto bound = std::bind(&foo::invoke_impl<Args...>, this,
                           std::placeholders::_1, std::forward<Args>(args)...);

    third_party(n, bound);
  }

  template <typename... Args>
  void invoke_impl(int, Args&&...)
  {
  }
};

foo f;
f.invoke(1, 2);

Problem polega na tym, że otrzymuję błąd kompilacji:

/usr/include/c++/4.7/functional:1206:35: error: cannot bind ‘int’ lvalue to ‘int&&’

Próbowałem użyć lambda, alemoże GCC 4.8 nie obsługuje jeszcze składni; oto co próbowałem:

auto bound = [this, &args...] (int k) { invoke_impl(k, std::foward<Args>(args)...); };

Otrzymuję następujący błąd:

error: expected ‘,’ before ‘...’ token
error: expected identifier before ‘...’ token
error: parameter packs not expanded with ‘...’:
note:         ‘args’

Z tego, co rozumiem, kompilator chce utworzyć instancjęinvoke_impl z typemint&&, podczas gdy myślałem, że to wykorzystuję&& w tym przypadku zachowałby rzeczywisty typ argumentu.

Co ja robię źle? Dzięki,

questionAnswers(1)

yourAnswerToTheQuestion