I have the following line of code that works on C++11 Red Hat Linux:
struct ConvertIfHasBrief< Obj, ObjResult, void_t< decltype( declval<ObjResult>().xData.xBrief ) > >
But I need this to also work on older version of C++ on an older version of Solaris. I'm having trouble figuring out what version of cc it has, but it's SunOS 5.9.
I've tried looking for alternative ways of writing this, but haven't found anything that even seems similar. Below is the whole file if it helps:
template< typename Ts >
struct make_void
{
typedef void type;
};
template< typename Ts >
struct void_t
{
using make_void<Ts>::type;
};
template< class Obj, class ObjResult, class = void >
struct ConvertIfHasBrief
{
static auto Convert( Obj const &, ObjResult & ) -> CLStatus
{
return {}; // dummy value, not used
}
};
template< class Obj, class ObjResult >
struct ConvertIfHasBrief< Obj, ObjResult, void_t< decltype( declval<ObjResult>().xData.xBrief ) > >
{
static auto Convert( Obj const &xFrom, ObjResult &xTo ) -> CLStatus
{
return ::Convert( xFrom, xTo.xData.xBrief );
}
};
template< class Obj, class ObjResult >
CLStatus convertObjToResult( const Obj & xFrom, ObjResult & xTo )
{
CLStatus eStatus = CLSTATUS_SUCCESS;
switch ( xTo.eType )
{
case CEPTFull:
xTo.xData.xFull = xFrom;
break;
case CEPTBrief:
eStatus = ConvertIfHasBrief< Obj, ObjResult >::Convert( xFrom, xTo );
break;
default:
eStatus = CLSTATUS_INVALIDPROJECTIONTYPE;
}
return eStatus;
}
And for further reference, this is the question that this code resulted from: Can I have a single template with a variable object?