1#ifndef LIBSBX_SIGNAL_OBJECT_PTR_HPP_
2#define LIBSBX_SIGNAL_OBJECT_PTR_HPP_
6#include <libsbx/signals/to_weak.hpp>
8namespace sbx::signals {
10using object_ptr =
const void*;
12template<
typename Type>
13auto get_object_ptr(
const Type& value) -> object_ptr;
15template<
typename Type,
typename =
void>
17 static auto get(
const Type&) -> object_ptr {
22template<
typename Type>
25 return reinterpret_cast<object_ptr
>(value);
29template<
typename Type>
31 static auto get(
const Type& value) -> object_ptr {
32 auto object = value.lock();
34 return get_object_ptr(
object);
38template<
typename Type>
39struct object_pointer<Type, std::enable_if_t<!std::is_pointer_v<Type> && !is_weak_ptr_v<Type> && is_weak_ptr_compatible_v<Type>>> {
40 static auto get(
const Type& value) -> object_ptr {
41 return value ?
reinterpret_cast<object_ptr
>(value.get()) :
nullptr;
45template<
typename Type>
46auto get_object_ptr(
const Type& value) -> object_ptr {
A non-owning pointer that can be used to observe the value of a pointer.
Definition: observer_ptr.hpp:27
Definition: object_ptr.hpp:16