improve plugin facing api with c++ helpers
This commit is contained in:
@@ -21,29 +21,7 @@ void g_provideInstance__internal(const char* id, const char* version, const char
|
||||
|
||||
} // extern C
|
||||
|
||||
namespace internal {
|
||||
template<typename T>
|
||||
class g_type_version {
|
||||
typedef char yes[1];
|
||||
typedef char no [2];
|
||||
|
||||
template<typename C> static yes& test_version(decltype(&C::version));
|
||||
template<typename C> static no& test_version(...);
|
||||
|
||||
static bool const has_version = sizeof(test_version<T>(nullptr)) == sizeof(yes);
|
||||
static constexpr const char* get_version(void) {
|
||||
if constexpr (has_version) {
|
||||
return T::version;
|
||||
} else {
|
||||
return "UNK"; // default version
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
static constexpr const char* version = get_version();
|
||||
};
|
||||
} // internal
|
||||
|
||||
#include "./version_helper.inl"
|
||||
|
||||
// templated helper, use or make sure vtable is right
|
||||
template<typename T>
|
||||
|
||||
Reference in New Issue
Block a user