Add preliminary support for generic serialization#160
Add preliminary support for generic serialization#160sdebionne wants to merge 2 commits intoboostorg:developfrom
Conversation
593724f to
3e071dd
Compare
|
@HDembinski @robertramey Any chance that you guys find time to review this PR? If accepted, it would be great to have in 1.71... |
| static constexpr auto check(T*) | ||
| -> typename | ||
| std::is_same< | ||
| decltype(std::declval<T>().serialize(std::declval<Archive&>(), std::declval<unsigned int>())), |
There was a problem hiding this comment.
Where is Archive& coming from here?
|
|
||
| BOOST_STRONG_TYPEDEF(unsigned int, version_type) | ||
|
|
||
| #if __cplusplus==201103L |
There was a problem hiding this comment.
Use detection from boost.config instead of raw checks like this.
| #include <boost/config.hpp> | ||
| #include <boost/serialization/strong_typedef.hpp> | ||
|
|
||
| #if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) |
There was a problem hiding this comment.
You don't need <type_traits>, versions of enable_if and is_same are in boost.core.
| template<class> | ||
| static constexpr std::false_type check(...); | ||
|
|
||
| typedef decltype(check<C>(0)) type; |
There was a problem hiding this comment.
Perhaps Boost.Concept should be used instead of writing this manually.
|
I am not the maintainer of this library, but here is a review. |
|
The whole check can be implemented in pre-C++11 code, I think. https://stackoverflow.com/questions/257288/is-it-possible-to-write-a-template-to-check-for-a-functions-existence |
Take serious look at Boost config. It has been the cornerstone of boost serialization portability. People take boost serialization portability for granted, but it's in fact an incredible feat which is totally due to the efforts of John Maddock's Boost config. I never test for any specific C++ version - only the existence of a capability as specified by boost config. It has to be this way because compilers which purport to support C++11 are not all in sync which combination of C++11 features they support. The fact is that there is no defacto C++ standard - only a theoretical one.
easy. look through the bjam test files and the tests themselves. |
|
@robertramey I share your admiration of boost.config :) |
…ialization namespace
See #113 for the rationale.
One possible use case is generic support for Boost.Hana Structs that have some level of reflection:
Let me know if there is a better way to properly test for std=c++11 and the availability of <type_traits>.
Is there any other place in the library where functionalities are conditionally supported given a c++ standard level?