mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-14 06:55:50 +02:00
Use OR instead of AND for all classes that have multiple types.
Revert example. Combination of has_as and not has_as are move to tests.
This commit is contained in:
@@ -159,6 +159,57 @@ TEST(MSGPACK_BOOST, pack_convert_no_def_con)
|
||||
|
||||
#endif // !defined(_MSC_VER)
|
||||
|
||||
struct mystruct_no_def_con_def_con {
|
||||
mystruct_no_def_con_def_con() = delete;
|
||||
// Constructor that have parameters corresponding to BOOST_FUSION_ADAPT_STRUCT is mandatory.
|
||||
// See *1, *2, and *3
|
||||
mystruct_no_def_con_def_con(
|
||||
no_def_con1 i,
|
||||
no_def_con2 j,
|
||||
int k):
|
||||
f1(std::move(i)),
|
||||
f2(std::move(j)),
|
||||
f3(std::move(k)) {}
|
||||
|
||||
no_def_con1 f1;
|
||||
no_def_con2 f2;
|
||||
int f3;
|
||||
};
|
||||
|
||||
inline bool operator==(mystruct_no_def_con_def_con const& lhs, mystruct_no_def_con_def_con const& rhs) {
|
||||
return lhs.f1 == rhs.f1 && lhs.f2 == rhs.f2 && lhs.f3 == rhs.f3;
|
||||
}
|
||||
|
||||
inline bool operator!=(mystruct_no_def_con_def_con const& lhs, mystruct_no_def_con_def_con const& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
BOOST_FUSION_ADAPT_STRUCT(
|
||||
mystruct_no_def_con_def_con,
|
||||
f1, // *1
|
||||
f2, // *2
|
||||
f3 // *3
|
||||
)
|
||||
|
||||
|
||||
// MSVC2015's std::tuple requires default constructor during 'as' process.
|
||||
// It doesn't support Expression SFINAE yet, then 'as' is fallbacked to 'convert'.
|
||||
// After MSVC would support Expression SFINAE, remove this guard.
|
||||
#if !defined(_MSC_VER)
|
||||
|
||||
TEST(MSGPACK_BOOST, pack_convert_no_def_con_def_con)
|
||||
{
|
||||
std::stringstream ss;
|
||||
mystruct_no_def_con_def_con val1(no_def_con1(1), no_def_con2(2), 3);
|
||||
msgpack::pack(ss, val1);
|
||||
msgpack::object_handle oh =
|
||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
mystruct_no_def_con_def_con val2 = oh.get().as<mystruct_no_def_con_def_con>();
|
||||
EXPECT_TRUE(val1 == val2);
|
||||
}
|
||||
|
||||
#endif // !defined(_MSC_VER)
|
||||
|
||||
#endif // !defined(MSGPACK_USE_CPP03
|
||||
|
||||
#endif // defined(MSGPACK_USE_BOOST)
|
||||
|
Reference in New Issue
Block a user