32 lines
615 B
C++
32 lines
615 B
C++
#ifndef BWIDGETS_OPAQUE_STRUCT_HPP
|
|
#define BWIDGETS_OPAQUE_STRUCT_HPP
|
|
|
|
namespace bwidgets
|
|
{
|
|
template<typename T>
|
|
class OpaqueStruct
|
|
{
|
|
protected:
|
|
T* _c_pod;
|
|
|
|
public:
|
|
OpaqueStruct(T* ptr = nullptr) : _c_pod(ptr) {}
|
|
virtual ~OpaqueStruct<T>() noexcept = default;
|
|
|
|
// NOLINTNEXTLINE(modernize-use-trailing-return-type)
|
|
[[nodiscard]] inline auto& operator()()
|
|
{
|
|
return _c_pod;
|
|
}
|
|
};
|
|
|
|
template<typename... Ts>
|
|
void discard(Ts*&... ptrs)
|
|
{
|
|
((delete ptrs), ...);
|
|
((ptrs = nullptr), ...);
|
|
}
|
|
}
|
|
|
|
#endif
|