boost::variant 单一存储保证
我的目标是保证所有变体类型的单一存储:根据 来自 Boost::variant 的“永不为空”保证,我们需要重写 对于每个有界类型,boost::has_nothro_copy
。但过了一会儿 该文档提到了一些关于 'boost::blank'
的内容,如果是的话 类型已绑定,变体将设置该值而不是尝试不抛出 默认复制构造函数。
不清楚的是是否在有界类型列表中添加 boost::blank 将避免覆盖/专门化 has_nothro_copy
的要求 与其他类型?
My goal is to guarantee single storage on all my variant types: according to 'never empty' guarantee from Boost::variant, we need to overrideboost::has_nothrow_copy
for each bounded type. But a bit later
the documentation mentions something about 'boost::blank'
and if that
type is bound, variant will set that value rather than try to nothrow
default copy constructors.
what is not clear is if adding boost::blank in the bounded type list
will avoid the requirement of overriding/specializing has_nothrow_copy
with the other types?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信这一点已经说得很清楚了。以下是 boost 文档中的相关部分:
由于
boost::blank
不可构造默认抛出异常,因此适用第二个子句。听起来 Boost 已经对这个特定类型进行了特殊处理,以有利于所有其他类型,这样就可以保证类型为boost::blank 如果这是一个选项。
I believe that is made clear. Here is the relevant section from the boost documentation:
Since
boost::blank
is nothrow default constructible, the second clause applies. And it sounds like Boost has special-cased this particular type to be chosen in favor of all others, so that instead of it being unspecified which default constructible type will be instantiated the type is guaranteed to beboost::blank
if that's an option.