mercredi 27 mars 2019

std::enable_if and std::conditional How to implement same functionality using c++98

In My project , std::enable_if and std::conditional is used . I have to support old GCC_VERSION. Could you please help me to implement std::enable_if and std::conditional 's functionality in C++98 ?

template<typename T>
using is_char = typename std::enable_if<sizeof (T) == sizeof (char)>::type;



template <typename ObjType,
            typename PtrType,
            typename CharType =
                typename std::conditional<std::is_const<PtrType>::value,
                                          const typename ObjType::char_type,
                                          typename ObjType::char_type>::type,
            typename = is_char<PtrType> >
    CharType* char_ptr_cast(PtrType* p)
    { return reinterpret_cast<CharType*>(p); }

Aucun commentaire:

Enregistrer un commentaire