eep*_*epp 5 c++ templates type-traits c++11 template-argument-deduction
当前代码:
#include <utility>
template <typename T, void (*D)(T *)>
std::pair<T *, void (*)(T *)> f(T * const t)
{
// ...
return std::make_pair(t, D); // need `T` and `D` here
}
void d(int *t);
void g()
{
auto something = f<int, d>(new int {5});
}
Run Code Online (Sandbox Code Playgroud)
我想要什么:
#include <utility>
template </* fill here: only `D` */>
std::pair<T *, void (*)(T *)> f(T * const t)
{
// ...
return std::make_pair(t, D); // need `T` and `D` here
}
void d(int *t);
void g()
{
auto something = f<d>(new int {5});
}
Run Code Online (Sandbox Code Playgroud)
这在 C++11 中可能吗?