为什么提振包括两个不同的版本strong

为什么提振包括两个不同的版本strong

本文介绍了为什么提振包括两个不同的版本strong_typedef.hpp的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

由于我最近正在建一个项目,我注意到,我得到了一个编译器警告(转向误差)有关 BOOST_STRONG_TYPEDEF 宏被重新定义。经进一步调查,我注意到,有两个不同版本的 strong_typedef.hpp 包含在提升:一是在顶层,还有一个在系列化/

As I was building a project recently, I noticed that I got a compiler warning (turned to error) about the BOOST_STRONG_TYPEDEF macro being redefined. Upon further investigation I noticed that there are two different versions of strong_typedef.hpp included in boost: One at the top level, and one within serialization/.

实际上有两个版本之间的差异,以及,不只是宏观的复制版本。顶级版本没有明确的价值,它的初始化 T 而序列化版本所做的:

There is actually a difference between the two versions as well, not just a duplicate version of the macro. The top level version doesn't explicitly value-init its T while the serialization version does:

code剪:

升压/ strong_typedef.hpp

    T t;                                                        \
    explicit D(const T t_) : t(t_) {};                          \
    D(){};                                                      \
    D(const D & t_) : t(t_.t){}                                 \

升压/系列化/ strong_typedef.hpp

    T t;                                                        \
    explicit D(const T t_) : t(t_) {};                          \
    D(): t() {};                                                \
    D(const D & t_) : t(t_.t){}                                 \

为什么有两个不同版本的宏,哪一个更有意义的实现?一,这将迫使内建类型被初始化,或者说,不将一(尽可能mimicing底层类型被强烈typedeffed)?

Why are there two different versions of the macro, and which one makes more sense as the implementation? The one that will force builtin types to be initialized, or the one that doesn't (as closely as possible mimicing the underlying type being strongly typedeffed)?

推荐答案

看起来升压/ strong_typedef.hpp 目录是一个历史产物。

It looks like boost/strong_typedef.hpp directory is a historical artifact.

缺少 T 成员明确初始化固定在升压/系列化/ strong_typedef.hpp错误几年前在SVN版本71183.请参见。

The lack of explicit initialization of the t member was a bug fixed in boost/serialization/strong_typedef.hpp a couple years ago in svn revision 71183. See the bug ticket.

在Boost的颠覆树干,<$c$c>boost/strong_typedef.hpp是说,一个主要是空文件:

In Boost's Subversion trunk, boost/strong_typedef.hpp is a largely empty file that says:

#error "This header is deprecated. Please use: boost/serialization/strong_typedef.hpp"

这变化,r48575,有人早在2008年 - 我不知道为什么它从来没有被合并成一个版本。也许是因为它会破坏用户无需大量的上攻或也许这是一个疏忽。同样的变化(r48575)是什么创造升压/系列化/ strong_typedef.hpp 在树干。

That change, r48575, was made back in 2008 - I don't know why it has never been merged into a release. Maybe because it would break users without a lot of upside or maybe it's an oversight. That same change (r48575) was what created boost/serialization/strong_typedef.hpp in trunk.

如果他们不希望打破现有的用户,那么也许去precated文件应该只包括文件升压/序列化所以有一个单一的,规范执行。在任何情况下,它会出现,如果你能避免使用系列化赞成使用的一C>,这就是我建议。

If they don't want to break existing users, then maybe the deprecated file should just include the file in boost/serialization so there's a single, canonical implementation. In any case, it would appear that if you can avoid using boost/strong_typedef.hpp in favor of using the one in serialization, that's what I'd suggest.

作为一个方面说明,记住,一年前升压序列化的作者(和 strong_typedef.hpp ),鲍勃·雷米,的评论,你可能会感兴趣

As a side note, keep in mind that a year ago the author of Boost Serialization (and strong_typedef.hpp), Bob Ramey, posted a comment in another bug ticket about strong_typedef.hpp that you might find interesting:

我不认为序列化库使用此了。当然,它仍然在那里。我不知道是否有人使用它。

这篇关于为什么提振包括两个不同的版本strong_typedef.hpp的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 22:33