2#ifndef LIBSBX_SIGNAL_OBJECT_PTR_HPP_
3#define LIBSBX_SIGNAL_OBJECT_PTR_HPP_
7#include <libsbx/signals/to_weak.hpp>
9namespace sbx::signals {
11using object_ptr =
const void*;
13template<
typename Type>
14auto get_object_ptr(
const Type& value) -> object_ptr;
16template<
typename Type,
typename =
void>
18 static auto get(
const Type&) -> object_ptr {
23template<
typename Type>
26 return reinterpret_cast<object_ptr
>(value);
30template<
typename Type>
32 static auto get(
const Type& value) -> object_ptr {
33 auto object = value.lock();
35 return get_object_ptr(
object);
39template<
typename Type>
40struct object_pointer<Type, std::enable_if_t<!std::is_pointer_v<Type> && !is_weak_ptr_v<Type> && is_weak_ptr_compatible_v<Type>>> {
41 static auto get(
const Type& value) -> object_ptr {
42 return value ?
reinterpret_cast<object_ptr
>(value.get()) :
nullptr;
46template<
typename Type>
47auto 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:28
Definition: object_ptr.hpp:17