【发布时间】:2019-04-17 22:42:29
【问题描述】:
我有以下两个结构:
template<typename T>
struct one { /* ... */ };
template<template<typename...> typename T>
struct two { /* ... */ };
当我有这样的示例实例化/未实例化模板时:
template<typename T>
struct sample_templated { /* ... */ };
using instantiated = sample_templated<double>;
那我就可以了
one<instantiated>{};
two<sample_templated>{};
很好。不过,我想合并 one 和 two 的定义,使它们具有相同的名称,因为这将允许递归。
我尝试使用默认定义,例如
template<typename...>
struct types_match_impl;
并让两个原始结构成为 this 的部分特化,但这与 two 不兼容。
这里的解决方案是什么?
【问题讨论】:
-
目前还不清楚你到底想要什么,但我猜你想将
types_match_impl传递给它自己。你能展示你想写的代码,并描述你认为它应该做什么吗?
标签: c++ templates template-specialization partial-specialization