I want to get a templatized way of finding if a type is a shared_ptr and based on that I want to have a new specialization of a function.
Example main function is,
template <class T> inline
void CEREAL_LOAD_FUNCTION_NAME( RelaxedJSONInputArchive & ar, NameValuePair<T> & t )
{
std::cout << " CEREAL_LOAD_FUNCTION_NAME NameValuePair 1 " << std::endl;
ar.setNextName( t.name );
ar( t.value );
}
If t.value is shared_ptr then I want to have a different function specialization. I have tried below,
template <class T> inline
typename std::enable_if<is_pointer<T>::value, void>::type
CEREAL_LOAD_FUNCTION_NAME( RelaxedJSONInputArchive & ar, NameValuePair<T> & t )
{
std::cout << " CEREAL_LOAD_FUNCTION_NAME NameValuePair 2 " << std::endl;
ar.setNextName( t.name );
ar( t.value );
}
But it does not seem to work. These are part of c++11 cereal library. Which I am trying to customize.
NameValuePair
have a member type telling you whatt.value
is? – Forewoman