50 template <
typename A,
typename B>
51 static auto Unwrap(B &x) -> Constify<A, B> * {
52 if constexpr (std::is_same_v<std::decay_t<A>, std::decay_t<B>>) {
60 template <
typename A,
typename B>
61 static auto Unwrap(B *p) -> Constify<A, B> * {
69 template <
typename A,
typename B>
70 static auto Unwrap(
const std::unique_ptr<B> &p) -> Constify<A, B> * {
78 template <
typename A,
typename B>
79 static auto Unwrap(
const std::shared_ptr<B> &p) -> Constify<A, B> * {
87 template <
typename A,
typename B>
88 static auto Unwrap(std::optional<B> &x) -> Constify<A, B> * {
96 template <
typename A,
typename B>
97 static auto Unwrap(
const std::optional<B> &x) -> Constify<A, B> * {
105 template <
typename A,
typename... Bs>
106 static A *Unwrap(std::variant<Bs...> &u) {
107 return common::visit(
109 using Ty = std::decay_t<decltype(Unwrap<A>(x))>;
110 if constexpr (!std::is_const_v<std::remove_pointer_t<Ty>> ||
111 std::is_const_v<A>) {
119 template <
typename A,
typename... Bs>
120 static auto Unwrap(
const std::variant<Bs...> &u) -> std::add_const_t<A> * {
121 return common::visit(
122 [](
const auto &x) -> std::add_const_t<A> * {
return Unwrap<A>(x); }, u);
125 template <
typename A,
typename B>
126 static auto Unwrap(
const Reference<B> &ref) -> Constify<A, B> * {
127 return Unwrap<A>(*ref);
130 template <
typename A,
typename B,
bool COPY>
132 return Unwrap<A>(p.value());
135 template <
typename A,
typename B>
138 return Unwrap<A>(*p);