SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
SDL3pp_objParam.h
1#ifndef SDL3PP_OBJ_PARAM_H_
2#define SDL3PP_OBJ_PARAM_H_
3
4#include <cstdlib>
5
6namespace SDL {
7
9template<typename RAW_POINTER>
11{
12public:
13 using RawPointer = RAW_POINTER;
14
16 constexpr ObjParam(RawPointer resource)
17 : m_resource(resource)
18 {
19 }
20
22 constexpr ObjParam(std::nullptr_t = nullptr)
23 : m_resource(nullptr)
24 {
25 }
26
28 constexpr explicit operator bool() const { return !!m_resource; }
29
31 constexpr auto operator<=>(const ObjParam& other) const = default;
32
34 constexpr operator RawPointer() const { return m_resource; }
35
37 constexpr auto operator->() const { return m_resource; }
38
39private:
40 RawPointer m_resource;
41};
42
44template<typename RAW_POINTER, typename RAW_CONST_POINTER>
46{
47public:
48 using RawPointer = RAW_POINTER;
49 using RawConstPointer = RAW_CONST_POINTER;
50
52 constexpr ObjConstParam(RawConstPointer resource)
53 : m_resource(resource)
54 {
55 }
56
58 constexpr ObjConstParam(std::nullptr_t = nullptr)
59 : m_resource(nullptr)
60 {
61 }
62
64 constexpr explicit operator bool() const { return !!m_resource; }
65
67 constexpr auto operator<=>(const ObjConstParam& other) const = default;
68
70 constexpr operator RawConstPointer() const { return m_resource; }
71
73 constexpr operator RawPointer() const
74 {
75 return const_cast<RawPointer>(m_resource);
76 }
77
79 constexpr auto operator->() const { return m_resource; }
80
81private:
82 RawConstPointer m_resource;
83};
84
85} // namespace SDL
86
87#endif /* SDL3PP_OBJ_PARAM_H_ */
constexpr auto operator->() const
member access to underlying type.
Definition SDL3pp_objParam.h:79
constexpr ObjConstParam(RawConstPointer resource)
Constructs from const pointer.
Definition SDL3pp_objParam.h:52
constexpr auto operator<=>(const ObjConstParam &other) const =default
Comparison.
constexpr ObjConstParam(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition SDL3pp_objParam.h:58
constexpr auto operator->() const
member access to underlying type.
Definition SDL3pp_objParam.h:37
constexpr ObjParam(RawPointer resource)
Constructs from RawPointer.
Definition SDL3pp_objParam.h:16
constexpr ObjParam(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition SDL3pp_objParam.h:22
constexpr auto operator<=>(const ObjParam &other) const =default
Comparison.
Main include header for the SDL3pp library.