diff --git a/source/mijin/util/annot.hpp b/source/mijin/util/annot.hpp index d1dd3e9..6ee18e4 100644 --- a/source/mijin/util/annot.hpp +++ b/source/mijin/util/annot.hpp @@ -35,6 +35,10 @@ concept nullable_type = !std::is_same_v && requires(T t) { t template class NotNullable { +public: + using wrapped_t = T; + using element_type = std::remove_reference_t())>; + using pointer = element_type*; private: T base_; public: @@ -55,6 +59,12 @@ public: { MIJIN_ASSERT(base_ != nullptr, "Constructed non-nullable type with nullptr."); } + template requires(std::is_base_of_v::element_type, element_type> && std::is_constructible_v) + explicit constexpr NotNullable(const NotNullable& other) MIJIN_NOEXCEPT_IF((std::is_nothrow_constructible_v)) + : base_(static_cast(&*other)) + { + MIJIN_ASSERT(base_ != nullptr, "Constructed non-nullable type with nullptr."); + } template requires(std::is_constructible_v) constexpr NotNullable(NotNullable&& other) MIJIN_NOEXCEPT_IF((std::is_nothrow_constructible_v)) : base_(std::exchange(other.base_, nullptr))