30 #ifndef CEREAL_ARCHIVES_ADAPTERS_HPP_
31 #define CEREAL_ARCHIVES_ADAPTERS_HPP_
38 #ifdef CEREAL_FUTURE_EXPERIMENTAL
41 template <
class U,
class A> U & get_user_data( A & );
108 template <
class UserData,
class Archive>
109 class UserDataAdapter :
public Archive
119 template <
class ... Args>
120 UserDataAdapter( UserData & ud, Args && ... args ) :
121 Archive( std::forward<Args>( args )... ),
128 friend UserData & get_user_data<UserData>( Archive & ar );
148 template <
class UserData,
class Archive>
149 UserData & get_user_data( Archive & ar )
153 return dynamic_cast<UserDataAdapter<UserData, Archive> &
>( ar ).userdata;
155 catch( std::bad_cast
const & )
157 throw ::cereal::Exception(
"Attempting to get user data from archive not wrapped in UserDataAdapter");
160 #endif // CEREAL_FUTURE_EXPERIMENTAL
163 #endif // CEREAL_ARCHIVES_ADAPTERS_HPP_