C++ : 混合 : boost::any +类型ID +指针:克隆“通用”;如果它是一个指针,则为值
这是我想做的:
- 从
boost::any
我想知道它是一个指针类型。 - 如果它是一个指针,我必须克隆它
类似这样的事情:
boost::any value= new vector<string>();
if (typeid(value).IsPointerType())
{
boost::any newValue = Clone(value);
}
你认为这可能吗?
感谢您的帮助
注意:我需要一个应该能够初始化默认值的框架。
Here is what I would like to do:
- From a
boost::any
I would like to know it is a pointer type. - If it is a pointer, I have to clone it
Something like this :
boost::any value= new vector<string>();
if (typeid(value).IsPointerType())
{
boost::any newValue = Clone(value);
}
Do you think that it is possible ?
Thanks for your help
NB: I need this for a framework that should be able to initialize Default value.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以使用这样的东西(没有编译它):
You could use something like this (didn't compile it):
您可以使用 type_info 接口:
返回
You can use the type_info interface:
Returns