21 :
ptr{
const_cast<void *
>(
reinterpret_cast<const void *
>(
ptr))},
28 if (
typeid(T) !=
type())
29 throw std::bad_any_cast();
31 throw std::bad_any_cast();
32 return reinterpret_cast<T *
>(
ptr);
35 [[nodiscard]]
bool has_value() const noexcept {
return ptr !=
nullptr; }
37 [[nodiscard]]
const std::type_info &
type() const noexcept {
43 const std::type_info *
ptr_type = &
typeid(void);
55 const_cast<void *
>(
reinterpret_cast<const void *
>(
ptr.get()))},
66 if (
typeid(T) !=
type())
67 throw std::bad_any_cast();
69 throw std::bad_any_cast();
70 return reinterpret_cast<T *
>(
ptr.get());
73 [[nodiscard]]
bool has_value() const noexcept {
return bool{
ptr}; }
75 [[nodiscard]]
const std::type_info &
type() const noexcept {
80 std::shared_ptr<void>
ptr;
81 const std::type_info *
ptr_type = &
typeid(void);
bool is_immutable() const noexcept
const std::type_info * ptr_type
const std::type_info & type() const noexcept
bool has_value() const noexcept
bool has_value() const noexcept
const std::type_info * ptr_type
shared_any_ptr(std::shared_ptr< T > ptr) noexcept
shared_any_ptr(const shared_any_ptr &)=default
const std::type_info & type() const noexcept
shared_any_ptr(shared_any_ptr &&) noexcept=default
bool is_immutable() const noexcept
std::shared_ptr< void > ptr