6 #ifndef TURI_HAS_LOAD_HPP 7 #define TURI_HAS_LOAD_HPP 10 #include <type_traits> 13 namespace archive_detail {
21 template<
typename ArcType,
typename T>
22 struct has_load_method
24 template<
typename U,
void (U::*)(ArcType&)>
struct SFINAE {};
25 template<
typename U>
static char Test(SFINAE<U, &U::load>*);
26 template<
typename U>
static int Test(...);
27 static const bool value =
sizeof(Test<T>(0)) ==
sizeof(char);
39 template <
typename ArcType,
typename ValueType>
40 typename std::enable_if<has_load_method<ArcType, ValueType>::value,
void>::type
41 load_or_fail(ArcType& o, ValueType &t) {
54 template <
typename ArcType,
typename ValueType>
55 typename std::enable_if<!has_load_method<ArcType, ValueType>::value,
void>::type
56 load_or_fail(ArcType& o, ValueType &t) {
57 ASSERT_MSG(
false,
"Trying to deserializable type %s without valid load method.",
typeid(ValueType).name());