我遇到了编译问题.我不明白为什么下面的代码不能编译:
#include <functional>
namespace async {
template<class ...T>
using Callback = std::function<void(const std::string& result, T ...args)>;
template<class Signature>
class Function;
template<class Res, class ...Args>
class Function<Res(Args...)>
{
std::function<void(Args ...args, const Callback<Res>&)> m_function;
public:
Function(std::function<void(Args ...args, const Callback<Res>&)>&& function) : m_function(std::move(function)) {}
Function& operator=(std::function<void(Args ...args, const Callback<Res>&)>&& function) {m_function = std::move(function); return *this;}
void operator()(Args... args, const Callback<Res>& callback) const {m_function(args..., callback);}
};
}
async::Function<int(int)> getF()
{
return [](int i, const async::Callback<int> callback)
{
callback("", i);
};
}
int main(int argc, …Run Code Online (Sandbox Code Playgroud)