13#define MACSTD_NONCOPYABLE(C) \
15 C (_In_ const C &h) noexcept; \
16 C& operator=(_In_ const C &h) noexcept;
21#define MACSTD_NONMOVABLE(C) \
23 C (_Inout_ C &&h) noexcept; \
24 C& operator=(_Inout_ C &&h) noexcept;
33#define MACSTD_STACK_BUFFER_BYTES 1024
38#define MACSTD_HANDLE_IMPL(C, T, INVAL) \
41 C (_In_opt_ T h) noexcept : handle<T, INVAL>( h ) {} \
42 C (_Inout_ C &&h) noexcept : handle<T, INVAL>(std::move(h)) {} \
43 C& operator=(_In_opt_ T h) noexcept { handle<T, INVAL>::operator=( h ); return *this; } \
44 C& operator=(_Inout_ C &&h) noexcept { handle<T, INVAL>::operator=(std::move(h)); return *this; } \
50#define MACSTD_DPLHANDLE_IMPL(C, T, INVAL) \
53 C (_In_opt_ T h) noexcept : dplhandle<T, INVAL>( h ) {} \
54 C (_In_ const C &h) noexcept : dplhandle<T, INVAL>(duplicate_internal(h.m_h)) {} \
55 C (_Inout_ C &&h) noexcept : dplhandle<T, INVAL>(std::move (h )) {} \
56 C& operator=(_In_opt_ T h) noexcept { dplhandle<T, INVAL>::operator=( h ); return *this; } \
57 C& operator=(_In_ const C &h) noexcept { dplhandle<T, INVAL>::operator=( h ); return *this; } \
58 C& operator=(_Inout_ C &&h) noexcept { dplhandle<T, INVAL>::operator=(std::move(h)); return *this; } \
68 template <
class T, const T INVAL>
120 #pragma warning(suppress: 26432)
123 if (
this != std::addressof(h)) {
150 assert(
m_h != INVAL);
160 assert(
m_h == INVAL);
171 assert(
m_h != INVAL);
318 template <class T, T INVAL>
349 dplhandle<T, INVAL>(_Inout_ dplhandle<T, INVAL> &&h) noexcept :
handle<T, INVAL>(std::move(h))
370 if (
this != std::addressof(h)) {
371 if (h.m_h != INVAL) {
372 T h_new = duplicate_internal(h.m_h);
374 if (this->m_h != INVAL)
379 if (this->m_h != INVAL)
393 #pragma warning(disable: 26432)
407 return this->m_h != INVAL ? duplicate_internal(this->m_h) : INVAL;
417 if (this->m_h != INVAL)
420 this->m_h = h != INVAL ? duplicate_internal(h) : INVAL;
Base abstract template class to support object handle keeping for objects that support trivial handle...
Definition common.hpp:320
dplhandle() noexcept
Initializes a new class instance with the object handle set to INVAL.
Definition common.hpp:325
virtual T duplicate_internal(T h) const =0
Abstract member function that must be implemented by child classes to do the actual object handle dup...
dplhandle< T, INVAL > & operator=(T h) noexcept
Attaches already available object handle.
Definition common.hpp:357
dplhandle< T, INVAL > & operator=(dplhandle< T, INVAL > &&h) noexcept
Moves the object.
Definition common.hpp:394
dplhandle(T h) noexcept
Initializes a new class instance with an already available object handle.
Definition common.hpp:333
void attach_duplicated(T h)
Duplicates an object handle and sets a new object handle.
Definition common.hpp:415
T duplicate() const
Duplicates and returns a new object handle.
Definition common.hpp:405
dplhandle< T, INVAL > & operator=(const dplhandle< T, INVAL > &h) noexcept
Duplicates the object.
Definition common.hpp:368
Base abstract template class to support generic object handle keeping.
Definition common.hpp:70
bool operator>=(T h) const
Is handle greater than or equal to?
Definition common.hpp:224
handle< T, INVAL > & operator=(handle< T, INVAL > &&h) noexcept
Move assignment.
Definition common.hpp:121
bool operator<=(T h) const
Is handle less than or equal to?
Definition common.hpp:211
handle() noexcept
Initializes a new class instance with the object handle set to INVAL.
Definition common.hpp:75
handle(T h) noexcept
Initializes a new class instance with an already available object handle.
Definition common.hpp:83
virtual void free_internal() noexcept=0
Abstract member function that must be implemented by child classes to do the actual object destructio...
void attach(T h) noexcept
Sets a new object handle for the class.
Definition common.hpp:275
bool operator==(T h) const
Is handle equal to?
Definition common.hpp:263
T * operator&()
Returns the object handle reference.
Definition common.hpp:158
bool operator>(T h) const
Is handle greater than?
Definition common.hpp:237
T *& operator*() const
Returns the object handle value when the object handle is a pointer to a value (class,...
Definition common.hpp:148
T m_h
Object handle.
Definition common.hpp:312
bool operator!() const
Tests if the object handle is invalid.
Definition common.hpp:185
handle< T, INVAL > & operator=(T h) noexcept
Attaches already available object handle.
Definition common.hpp:109
T detach()
Dismisses the object handle from this class.
Definition common.hpp:287
bool operator!=(T h) const
Is handle not equal to?
Definition common.hpp:250
bool operator<(T h) const
Is handle less than?
Definition common.hpp:198
handle(handle< T, INVAL > &&h) noexcept
Move constructor.
Definition common.hpp:91
void free()
Destroys the object.
Definition common.hpp:297
T operator->() const
Provides object handle member access when the object handle is a pointer to a class or struct.
Definition common.hpp:169