Commit 2bcb1d2e authored by Matthias Vallentin's avatar Matthias Vallentin

Make has_serialize meta function symmetric

It previously only checked for serialization, not deserialization.
parent daf900c1
......@@ -269,7 +269,10 @@ template <class F, class S>
struct is_tuple<std::pair<F, S>> : std::true_type { };
/// Checks whether `T` provides either a free function or a member function for
/// serialization. The following signatures are tested:
/// serialization. The checks test whether both serialization and
/// deserialization can succeed. The meta function tests the following
/// functions with `Processor` being both `serializer` and `deserializer` and
/// returns an integral constant if and only if the test succeeds for both.
///
/// - `serialize(Processor&, T&, const unsigned int)`
/// - `serialize(Processor&, T&)`
......@@ -280,25 +283,50 @@ template <class T,
|| std::is_function<T>::value>
struct has_serialize {
template <class U>
static auto test(caf::serializer* sink, U* x)
static auto test_serialize(caf::serializer* sink, U* x)
-> decltype(serialize(*sink, *x, 0u), std::true_type());
template <class U>
static auto test(caf::serializer* sink, U* x)
static auto test_serialize(caf::serializer* sink, U* x)
-> decltype(serialize(*sink, *x), std::true_type());
template <class U>
static auto test(caf::serializer* sink, U* x)
static auto test_serialize(caf::serializer* sink, U* x)
-> decltype(x->serialize(*sink, 0u), std::true_type());
template <class U>
static auto test(caf::serializer* sink, U* x)
static auto test_serialize(caf::serializer* sink, U* x)
-> decltype(x->serialize(*sink), std::true_type());
template <class>
static auto test(...) -> std::false_type;
static auto test_serialize(...) -> std::false_type;
template <class U>
static auto test_deserialize(caf::deserializer* source, U* x)
-> decltype(serialize(*source, *x, 0u), std::true_type());
template <class U>
static auto test_deserialize(caf::deserializer* source, U* x)
-> decltype(serialize(*source, *x), std::true_type());
template <class U>
static auto test_deserialize(caf::deserializer* source, U* x)
-> decltype(x->serialize(*source, 0u), std::true_type());
template <class U>
static auto test_deserialize(caf::deserializer* source, U* x)
-> decltype(x->serialize(*source), std::true_type());
template <class>
static auto test_deserialize(...) -> std::false_type;
using serialize_type = decltype(test_serialize<T>(nullptr, nullptr));
using deserialize_type = decltype(test_deserialize<T>(nullptr, nullptr));
using type = std::integral_constant<
bool,
serialize_type::value && deserialize_type::value
>;
using type = decltype(test<T>(nullptr, nullptr));
static constexpr bool value = type::value;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment