rig*_*old 1 c++ syntax templates
考虑以下:
template<typename R>
struct call {
template<typename F, typename... Args>
explicit call(F&& f, Args&&... args);
R result;
};
template<typename R, typename F, typename... Args>
call<R>::call(F&& f, Args&&... args)
: result(std::forward<F>(f)(std::forward<Args>(args)...)) { }
Run Code Online (Sandbox Code Playgroud)
clang对我大吼:
utility.tpp:40:1: error: too many template parameters in template redeclaration
template<typename R, typename F, typename... Args>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
utility.hpp:36:5: note: previous template declaration is here
template<typename R>
^~~~~~~~~~~~~~~~~~~~
我完全不解.有可能吗?
您需要两个模板:一个用于类,一个用于构造函数:
template <typename R> // <== for call<R>
template <typename F, typename... Args> // <== for call(F&&, Args&&...)
call<R>::call(F&& f, Args&&... args)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
384 次 |
| 最近记录: |