-
Notifications
You must be signed in to change notification settings - Fork 768
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
Develop #423
Develop #423
Conversation
The third commit makes sure the specialization for |
This is in addition to the feedback presented in #418, since these PRs seem to be related. This PR is against the develop branch so you can disregard that comment. Since one of our targets is MSVC 2013, we can't use |
Thank you for your helpful feedback! I don't understand the last comment, we didn't add any |
@AzothAmmo I tried removing the unnecessary copies altogether and use |
Ah never mind, the |
I'll review this and likely merge either this weekend or early next week, pushing out a small release shortly thereafter with the other develop changes. |
Awesome, thank you! |
I added unit tests for Furthermore, I noticed |
OK, one more thing that I noticed: |
Are you sure you don't mean std::remove_cv instead of std::remove_const? |
I am not sure why |
std::decay does 3 things: Removes constant, removes volatile, and removes reference. I'm not sure why it would turn T* into T however... I haven't looked closely at this component, but I presume that if we meant to remove const, we likely wanted to remove volatile, particularly since it has some pretty nasty performance/allocation gotchas. |
Sorry, I meant to write I am uncertain about I'm also uncertain about removing references. From what I can tell, @erichkeane So maybe you can provide more reasoning as to why remove |
Ah, that makes more sense... Volatile on some platforms requires different alignment requirements. Volatile in a shared_ptr requires a ton more OS loads, and hamstrings the optimizer. Additionally, we would end up generating an entirely new instance of the shared_ptr object in this case. I'm OK either way, I just want to make sure this is a behavior change being made intentionally. |
Looks good overall and no errors for normal stuff with unique and shared pointers. Testing with This reminds me that this also needs to be tested with polymorphic types. |
@AzothAmmo will you take care of that? I am not sure what to do to be honest. |
…yArchive to silence clang warning
Yes I'll take care of that when I merge this. |
Still on my todo list to merge, been very busy lately; should hopefully get this done in the near future (along with anything else marked 1.2.3). |
Looking to merge this as a pre-req for #448. Almost have a solution for load and construct. Test case I was playing with is: #include <fstream>
#include <iostream>
#include <cereal/cereal.hpp>
#include <cereal/access.hpp>
#include <cereal/archives/json.hpp>
#include <cereal/types/memory.hpp>
struct OneLA
{
OneLA( int xx ) : x( xx ) {}
int x;
template <class Archive>
void serialize( Archive & ar )
{ ar( x ); }
template <class Archive, class T>
static void load_and_construct( Archive & ar, cereal::construct<T> & construct )
{
int xx;
ar( xx );
construct( xx );
}
bool operator==( OneLA const & other ) const
{ return x == other.x; }
};
int main()
{
std::stringstream ss;
std::cerr << std::boolalpha;
std::cerr << cereal::traits::has_member_load_and_construct<OneLA, cereal::JSONOutputArchive>::value << std::endl;
std::cerr << cereal::traits::has_member_load_and_construct<const OneLA, cereal::JSONOutputArchive>::value << std::endl;
{
cereal::JSONOutputArchive ar( ss );
auto b = std::make_shared<const OneLA>( 3 );
ar( b );
}
std::cout << ss.str() << std::endl;
{
std::shared_ptr<const OneLA> b;
{
cereal::JSONInputArchive ar(ss);
ar( b );
}
cereal::JSONOutputArchive ar2(std::cout);
ar2( b );
}
} Requires changes in memory - std::shared_ptr<typename std::remove_const<T>::type> ptr(reinterpret_cast<T *>(new ST()),
- [=]( T * t )
+ using NonConstT = typename std::remove_const<T>::type;
+ std::shared_ptr<NonConstT> ptr(reinterpret_cast<NonConstT *>(new ST()),
+ [=]( NonConstT * t ) Need to play with this more and get rid of the extra template parameter I added for |
Progress towards USCiLab#448 Lots of warnings from g++7.2, these are addressed in USCiLab#423 which hasn't been merged yet. CMAKE can be cleaned up a bit - may put back in the ability to use older cmake and just throw errors as necessary, otherwise just force people to use at least cmake 3.1
Progress towards USCiLab#448 Lots of warnings from g++7.2, these are addressed in USCiLab#423 which hasn't been merged yet. CMAKE can be cleaned up a bit - may put back in the ability to use older cmake and just throw errors as necessary, otherwise just force people to use at least cmake 3.1
Progress towards USCiLab#448 Lots of warnings from g++7.2, these are addressed in USCiLab#423 which hasn't been merged yet. CMAKE can be cleaned up a bit - may put back in the ability to use older cmake and just throw errors as necessary, otherwise just force people to use at least cmake 3.1
Progress towards USCiLab#448 Lots of warnings from g++7.2, these are addressed in USCiLab#423 which hasn't been merged yet. CMAKE can be cleaned up a bit - may put back in the ability to use older cmake and just throw errors as necessary, otherwise just force people to use at least cmake 3.1
Progress towards USCiLab#448 Lots of warnings from g++7.2, these are addressed in USCiLab#423 which hasn't been merged yet. CMAKE can be cleaned up a bit - may put back in the ability to use older cmake and just throw errors as necessary, otherwise just force people to use at least cmake 3.1
Cereal updated for work being done in another branch. This bump fixes some issues with the library. Tested v1.3.1 Bug fixes and minor enhancements: Fix typo in docs by @tankorsmash in Fix typo in docs USCiLab/cereal#597 Add MSVC 2019 to build, default ctor for static object by @AzothAmmo in Add MSVC 2019 to build, default ctor for static object USCiLab/cereal#593 Fix json.hpp compilation issue when int32_t is a long by @bblackham in Fix json.hpp compilation issue when int32_t is a long USCiLab/cereal#621 [cpp20] explicitly capture 'this' as copy by @lukaszgemborowski in [cpp20] explicitly capture 'this' as copy USCiLab/cereal#640 Fix rapidjson for Clang 10 by @groscoe2 in Fix rapidjson for Clang 10 USCiLab/cereal#645 Fixes to prevent clang-diagnostic errors by @johngladp in Fixes to prevent clang-diagnostic errors USCiLab/cereal#643 cleanup cmake files to be a little more moderen by @ClausKlein in cleanup cmake files to be a little more moderen USCiLab/cereal#659 GHSA-wgww-fh2f-c855: Store a copy of each serialized shared_ptr within the archive to prevent the shared_ptr to be freed to early. by @serpedon in CVE-2020-11105: Store a copy of each serialized shared_ptr within the archive to prevent the shared_ptr to be freed to early. USCiLab/cereal#667 add license files for components of cereal by @miartad in add license files for components of cereal USCiLab/cereal#676 Catch short documents in JSON input by @johnkeeping in Catch short documents in JSON input USCiLab/cereal#677 C++17: use inline globals for StaticObjects by @InBetweenNames in C++17: use inline globals for StaticObjects USCiLab/cereal#657 Use std::variant::emplace when loading by @kepler-5 in Use std::variant::emplace when loading USCiLab/cereal#699 Use std::optional::emplace() when loading non-empty optional by @kepler-5 in Use std::optional::emplace() when loading non-empty optional USCiLab/cereal#698 Fix itsNextName not clearing when not found + style change by @AzothAmmo in Fix itsNextName not clearing when not found + style change USCiLab/cereal#715 Update doctest to 2.4.6 + local fixes slated for upstream by @AzothAmmo in Update doctest to 2.4.6 + local fixes slated for upstream USCiLab/cereal#716 Fixed loading of std::vector by @Darred in Fixed loading of std::vector<bool> USCiLab/cereal#732 Update license to match BSD template by @AzothAmmo in Update license to match BSD template USCiLab/cereal#735 Update doctest to 2.4.7 by @AzothAmmo in Update doctest to 2.4.7 USCiLab/cereal#736 Use GNUInstallDirs instead of hard wiring install directories by @antonblanchard in Use GNUInstallDirs instead of hard wiring install directories USCiLab/cereal#710 This is not an exhaustive list of changes or individual contributions. See the closed issues or complete changelog for more information. v1.3.0 New features include: Deferred serialization for smart pointers (Stack overflow for large chains of shared_ptr (or smart pointers in general) USCiLab/cereal#185) Initial support for C++17 standard library variant and optional (thanks to @arximboldi, Add serialization support for C++17 std::optional and std::variant USCiLab/cereal#448) Support for std::atomic (thanks to @bluescarni, Implementation and testing of std::atomic serialization. USCiLab/cereal#277) Fixes and enhancements include: Vastly improved continuous integration testing (Appveyor updates + boost testing fixes USCiLab/cereal#568, Update Travis CI USCiLab/cereal#569) Fixed several issues related to compilation on newer compilers (Fixing various compilation warnings USCiLab/cereal#579, Add fall through comments to json.hpp USCiLab/cereal#587, Fix warning unused private member itsValueItEnd USCiLab/cereal#515) Fixed warnings with -Wconversion and -Wdocumentation (thanks to @WSoptics, Develop USCiLab/cereal#423) Performance improvements for polymorphic serialization (PolymorphicVirtualCaster StaticObject instantiation takes a very long time at app startup USCiLab/cereal#354) Minor fixes and enhancements include: Fixed a bug related to CEREAL_REGISTER_DYNAMIC_INIT with shared libraries (thanks to @m2tm, Issue correctly using CEREAL_REGISTER_DYNAMIC_INIT USCiLab/cereal#523) Avoid unnecessary undefined behavior with StaticObject (thanks to @erichkeane, Change StaticObject instance management to hopefully avoid UBSAN USCiLab/cereal#470) New version.hpp file describes cereal version (detect cereal version at compile time / version.hpp USCiLab/cereal#444) Ability to disable size=dynamic attribute in the XML archive (thanks to @hoensr, Add option to turn off the size=dynamic attributes of lists USCiLab/cereal#401) Other Notes The static checking for minimal serialization has been relaxed as there were many legitimate cases it was interfering with (thanks to @h-2, remove const check from load_minimal USCiLab/cereal#565) The vs2013 directory has been removed in favor of generating solutions with CMake (Remove vs2013 directory USCiLab/cereal#574)
The second commit fixes many compiler warnings that GCC and Clang give when compiling with
-Wconversion
and-Wdocumentation
.