创建一个简单的脚本“语言”; - 类似 VARIANT 的值类型
对于用C++开发的规则引擎来说,核心特性之一就是值类型。到目前为止,我所拥有的有点像 COM 风格的 VARIANT - 每个值都知道它的类型。类型转换有一些规则,但有点混乱。
我想知道是否有很好的插入值类可以用来解决这个问题,而不需要我使用整个预构建的系统。例如,也许 boost 有什么东西?
For a rules engine developed in C++, one of the core features is the value type. What I have so far is a bit like a COM-style VARIANT - each value knows its type. There are some rules for type conversion but it's a bit messy.
I wondered if there are nice drop-in value classes I could use which solve this, without requiring me to use a whole pre-built system. For instance maybe boost has something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
寻找 boost::any 或 boost::variant?
变体实现基本上分为三种类型:
boost::lexical_cast
是你的朋友,或者boost::variant
...int
初始化,保持int
并且不允许像其他任何类型一样隐式处理 - 这是 < a href="http://www.boost.org/doc/html/any.html" rel="nofollow noreferrer">boost::any
类型void*
Looking for boost::any or boost::variant?
There are basically three types of variant implementations:
boost::lexical_cast
is your friend here, orboost::variant
...int
, stays anint
and doesn't allow to be treated implicitly like anything else -- this is theboost::any
typevoid*