diff --git a/src/c-wrapper/internal/c-tools.h b/src/c-wrapper/internal/c-tools.h index 0e64a5c78..b7d7f7050 100644 --- a/src/c-wrapper/internal/c-tools.h +++ b/src/c-wrapper/internal/c-tools.h @@ -48,16 +48,21 @@ struct CObjectInitializer {}; class Wrapper { private: - template - struct WrappedObject { - belle_sip_object_t base; - std::shared_ptr cppPtr; + template + struct IsCppObject { + enum { value = std::is_base_of::value || std::is_base_of::value }; }; - template + template + struct WrappedObject { + belle_sip_object_t base; + std::shared_ptr cppPtr; + }; + + template struct WrappedClonableObject { belle_sip_object_t base; - T *cppPtr; + CType *cppPtr; }; public: @@ -65,14 +70,20 @@ public: // Get private data of cpp Object. // --------------------------------------------------------------------------- - template - static inline decltype (std::declval().getPrivate()) getPrivate (T *cppObject) { + template< + typename CppType, + typename = typename std::enable_if::value, CppType>::type + > + static inline decltype (std::declval().getPrivate()) getPrivate (CppType *cppObject) { L_ASSERT(cppObject); return cppObject->getPrivate(); } - template - static inline decltype (std::declval().getPrivate()) getPrivate (const std::shared_ptr &cppObject) { + template< + typename CppType, + typename = typename std::enable_if::value, CppType>::type + > + static inline decltype (std::declval().getPrivate()) getPrivate (const std::shared_ptr &cppObject) { L_ASSERT(cppObject); return cppObject->getPrivate(); }