-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add preliminary support for generic serialization #160
base: develop
Are you sure you want to change the base?
Add preliminary support for generic serialization #160
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is Archive& coming from here?
@@ -60,6 +64,44 @@ namespace serialization { | |||
|
|||
BOOST_STRONG_TYPEDEF(unsigned int, version_type) | |||
|
|||
#if __cplusplus==201103L |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use detection from boost.config instead of raw checks like this.
@@ -13,6 +13,10 @@ | |||
#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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?