David Kahurani (@kahurani) commented about include/dxcore_interface.h:
- {
return QueryState(state, 0, NULL, sizeof(T), (void *)buffer);
- }
- template <class T1, class T2>
- HRESULT SetState(DXCoreAdapterState state, const T1 *input_state, const T2 *input_data)
- {
return SetState(state, sizeof(T1), (const void *)input_state, sizeof(T2), (const void *)input_data);
- }
- template <class T>
- HRESULT GetFactory(T **ppv)
- {
return GetFactory(IID_PPV_ARGS(ppv));
- }
- #endif
It seems like a few things are not correct with this code. This might not be important seeing the design of the code is still being discussed.
i) Casting to a constant which is what is happening for instance here `HRESULT GetProperty(DXCoreAdapterProperty property, (`**`sizeof`**`(T)) T `**`*`**`buffer)` . `sizeof` is a compile time operator which means if `sizeof(T)` evaluates to 5, for instance, this code is equivalent to `HRESULT GetProperty(DXCoreAdapterProperty property, (`**`5`**`) T `**`*`**`buffer)` . You can only cast to a type, of which 5 is not.
ii) Some functions, for instance, `STDMETHOD(GetProperty) (THIS_ DXCoreAdapterProperty property, `**`size_t`**` `**`*`**`buffer_size, `**`void`**` `**`*`**`buffer) PURE;` accept a buffer_size which is a pointer but instead of passing a pointer when overloading it, you pass `sizeof(T)` which, of course, is not a pointer.
From the looks of it, it looks like by using the templates, you are trying to overload the functions so it might be worth noting that by using templates you change the syntax used for calling the method to something like `Getfactory<int>(ppv)` . I am not sure this is a desired effect or a side effect of using the templates hence I am noting.