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/
.
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 snips:
boost/strong_typedef.hpp
:
T t; \
explicit D(const T t_) : t(t_) {}; \
D(){}; \
D(const D & t_) : t(t_.t){} \
boost/serialization/strong_typedef.hpp
:
T t; \
explicit D(const T t_) : t(t_) {}; \
D(): t() {}; \
D(const D & t_) : t(t_.t){} \
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)?
I am the author of both versions of boost/strong_typedef.hpp
.
Because of strident objections to inclusion to in the boost base header directly, I moved to the serialization library. In order to maintain backward compatibility, I left it in the boost base header directory. I forgot to merge this file into the release branch so the warning would appear. I also forgot to change the name to BOOST_SERIALIZATION_STRONG_TYPEDEF
. And since then I added the initialization to the base class. I guess since I made the split, I included a correction in version in the serialization library.
I just looked at the serialization library and usage of strong_typedef is now minimal. I guess I'll get around to removing it entirely. So then it would be disappear entirely.
It really should be a separate utility. But I can't really deal with all that boost requires (tests, docs, build, review). And boost doesn't have a really good place for these small header only utilities. I had one day hoped that these small utilities that I needed for the serialization library would migrate to the the boost base. But I came to be discouraged from that idea.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With