假设我有一个模板函数:
我怀疑答案是“你无法做到这一点”。
template
:template<typename T>
T produce_5_function() { return T(5); }
我该如何将整个模板
传递给另一个模板
?
如果produce_5_function
是一个函数对象,那就没有问题了:
template<typename T>
struct produce_5_functor {
T operator()() const { return T(5); }
};
template<template<typename T>class F>
struct client_template {
int operator()() const { return F<int>()(); }
};
int five = client_template< produce_5_functor >()();
但我希望能够使用原始函数模板来实现这一点:
template<??? F>
struct client_template {
int operator()() const { return F<int>(); }
};
int five = client_template< produce_5_function >()();
我怀疑答案是“你无法做到这一点”。