42 : native_(std::move(
native)) {}
45 constexpr operator T&()
noexcept {
50 constexpr operator const T&()
const noexcept {
70 constexpr const T*
handle() const noexcept {
75 constexpr const T&
native() const noexcept {
96 static std::false_type
check(...);
99 static constexpr bool value = type::value;
111template <
typename WrapperType>
114 static_assert(std::is_standard_layout_v<WrapperType>);
120 return static_cast<WrapperType*
>(
static_cast<void*
>(native));
124 return static_cast<const WrapperType*
>(
static_cast<const void*
>(native));
136 return static_cast<NativeType*
>(
static_cast<void*
>(wrapper));
140 return static_cast<const NativeType*
>(
static_cast<const void*
>(wrapper));
164template <
typename WrapperType,
typename NativeType =
typename WrapperType::NativeType>
165constexpr WrapperType*
asWrapper(NativeType* native)
noexcept {
170template <
typename WrapperType,
typename NativeType =
typename WrapperType::NativeType>
171constexpr const WrapperType*
asWrapper(
const NativeType* native)
noexcept {
177template <
typename WrapperType,
typename NativeType =
typename WrapperType::NativeType>
178constexpr WrapperType&
asWrapper(NativeType& native)
noexcept {
183template <
typename WrapperType,
typename NativeType =
typename WrapperType::NativeType>
184constexpr const WrapperType&
asWrapper(
const NativeType& native)
noexcept {
190template <
typename WrapperType,
typename NativeType =
typename WrapperType::NativeType>
191constexpr NativeType*
asNative(WrapperType* wrapper)
noexcept {
196template <
typename WrapperType,
typename NativeType =
typename WrapperType::NativeType>
197constexpr const NativeType*
asNative(
const WrapperType* wrapper)
noexcept {
203template <
typename WrapperType,
typename NativeType =
typename WrapperType::NativeType>
204constexpr NativeType&
asNative(WrapperType& wrapper)
noexcept {
209template <
typename WrapperType,
typename NativeType =
typename WrapperType::NativeType>
210constexpr const NativeType&
asNative(
const WrapperType& wrapper)
noexcept {
Template base class to wrap native objects.
constexpr const T * operator->() const noexcept
Member access to native object.
constexpr T * operator->() noexcept
Member access to native object.
constexpr const T & native() const noexcept
constexpr const T * handle() const noexcept
Return pointer to native object.
constexpr T & native() noexcept
constexpr T * handle() noexcept
Return pointer to native object.
constexpr Wrapper(T &&native) noexcept
constexpr Wrapper(const T &native)
constexpr Wrapper()=default
constexpr NativeType * asNative(WrapperType *wrapper) noexcept
Cast Wrapper object pointers to native object pointers.
Client * asWrapper(UA_Client *client) noexcept
Convert native UA_Client pointer to its wrapper instance.
static constexpr bool value
static std::true_type check(const Wrapper< U > &)
static std::false_type check(...)
decltype(check(std::declval< T & >())) type
static constexpr const WrapperType * asWrapper(const NativeType *native) noexcept
static constexpr NativeType * asNative(WrapperType *wrapper) noexcept
static constexpr const NativeType * asNative(const WrapperType *wrapper) noexcept
static constexpr WrapperType * asWrapper(NativeType *native) noexcept
static constexpr const WrapperType & asWrapper(const NativeType &native) noexcept
static constexpr NativeType & asNative(WrapperType &wrapper) noexcept
static constexpr WrapperType & asWrapper(NativeType &native) noexcept
typename WrapperType::NativeType NativeType
static constexpr const NativeType & asNative(const WrapperType &wrapper) noexcept