Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing serialization of classes with incompatible serialize signature
This fixes #3134
- Loading branch information
1 parent
f2eb5ae
commit 241a985
Showing
4 changed files
with
70 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
tests/unit/serialization/serialize_with_incompatible_signature.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) 2018 Anton Bikineev | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#include <hpx/runtime/serialization/serialize.hpp> | ||
#include <hpx/util/lightweight_test.hpp> | ||
|
||
#include <vector> | ||
|
||
struct A | ||
{ | ||
double a; | ||
int p; | ||
|
||
void serialize(int, unsigned) { | ||
// 3rd-party logic... | ||
} | ||
}; | ||
|
||
template <class Ar> | ||
void serialize(Ar& ar, A& a, unsigned) { | ||
ar & a.a; | ||
ar & a.p; | ||
} | ||
|
||
int main() | ||
{ | ||
std::vector<char> vector; | ||
{ | ||
hpx::serialization::output_archive oar(vector); | ||
A a{2., 4}; | ||
oar << a; | ||
} | ||
|
||
{ | ||
A a; | ||
hpx::serialization::input_archive iar(vector); | ||
iar >> a; | ||
HPX_TEST_EQ(a.a, 2.); | ||
HPX_TEST_EQ(a.p, 4); | ||
} | ||
|
||
return 0; | ||
} |