推断模板模板参数的类型
我需要推断参数模板的类型名称。然后将通过反思使用这些参数来实现我的目标。到目前为止,我已经提出了以下似乎可行的方法:
template <typename... F, typename T>
static void templateA(T t) {
/* Use reflection to obtain the types in F */
}
然后将这样调用:
template <typename T>
void templateB() {
/* Do some work */
}
templateA<float>(templateB<float>);
这可行,但我想知道是否可以从 F 推断模板 B 的类型?我正在尝试模板模板参数,但到目前为止它还不起作用。像这样:
template <typename... F, template<typename V> class T>
static void templateA(T<F...> t) {
/* Use reflection to obtain the types in F */
}
templateA<float>(templateB);
这可能吗?我知道这是一个有点令人困惑的用例,但希望有任何关于如何实现这一目标的提示。
I need to deduce the typenames of a parameter template. Those parameters would then be used with reflection to achieve my goal. So far I have come up with the following which seems to work:
template <typename... F, typename T>
static void templateA(T t) {
/* Use reflection to obtain the types in F */
}
Which would then be called like this:
template <typename T>
void templateB() {
/* Do some work */
}
templateA<float>(templateB<float>);
This works but I was wondering if it is possible to infer the types of template B from F? I'm trying template template parameters but so far it's not working. Something like this:
template <typename... F, template<typename V> class T>
static void templateA(T<F...> t) {
/* Use reflection to obtain the types in F */
}
templateA<float>(templateB);
Is this possible. I understand this is a bit confusing use case but would appreciate any tips on how to achieve this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论