如何检查模板类型参数是否是打字机?
我计划将BOOST :: MP11或BRIGAND用于我的TMP。在这里,我使用一些伪代码来说明我想做什么:
template< typename... Types >
class factory
{
// if the passing type is a typelist,
// then use for_each() to get types out of it one by one.
// else
// do something.
}
因此,类Factory
的用户可能会通过常规类型(INT,Bool等)或打字机(Brigand或MP11 Typelist)传递。 。我希望我的代码在类Factory
中可以从variadic模板包中选择类型,并根据是否是打字机进行不同的处理?例如:
factory<int, bool, typelist> f1;
factory<typelist1, int, typelist2> f2
factory<typelist> f3
我没有找到两个库(MP11,Brigand)提供任何设施功能来检查类型是否是打字机。有人可以分享一些想法吗?
I plan to use either boost::mp11 or brigand for my TMP. Here I use some pseudo code to illustrate what I want to do:
template< typename... Types >
class factory
{
// if the passing type is a typelist,
// then use for_each() to get types out of it one by one.
// else
// do something.
}
So the user of class factory
may pass in regular types (int, bool, etc.) or a typelist (either brigand or mp11 typelist). I want my code inside the class factory
can pick types from the variadic template pack and do different processing according to whether it's a typelist or not? For example:
factory<int, bool, typelist> f1;
factory<typelist1, int, typelist2> f2
factory<typelist> f3
I did not find the two libraries (mp11, brigand) provide any facility function to check whether a type is a typelist. Anyone can share some thoughts on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哦,刚才,我从mp11文档中找到了此
mp_is_list&lt; l&gt;
。我想我可以利用这一点。oh, just now, I found this
mp_is_list<L>
from MP11 document. I guess I can make use of that.