私がtemplate
関数を持っているとしましょう:
template<typename T>
T produce_5_function() { return T(5); }
template
この全体を別の人に渡すにはどうすればよいtemplate
ですか?
ファンクターであれば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 >()();
答えは「これはできない」と思います。