From 224048d0f4022f91c2074daddf9dcafbf11f2be9 Mon Sep 17 00:00:00 2001
From: Steven Le Rouzic <steven.lerouzic@gmail.com>
Date: Thu, 30 Jan 2025 23:34:12 +0100
Subject: Add implicit conversions for box from derived to base type

---
 asl/box.hpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

(limited to 'asl/box.hpp')

diff --git a/asl/box.hpp b/asl/box.hpp
index 795b6dd..9d3c7f0 100644
--- a/asl/box.hpp
+++ b/asl/box.hpp
@@ -35,6 +35,13 @@ public:
         , m_alloc{ASL_MOVE(other.m_alloc)}
     {}
 
+    template<is_object U>
+    requires convertible_from<T*, U*>
+    constexpr box(box<U, Allocator>&& other) // NOLINT(*-explicit-conversions)
+        : m_ptr{exchange(other.m_ptr, nullptr)}
+        , m_alloc{ASL_MOVE(other.m_alloc)}
+    {}
+
     constexpr box& operator=(box&& other)
     {
         if (this == &other) { return *this; }
@@ -93,6 +100,9 @@ public:
 
     template<is_object U, allocator A>
     friend constexpr U* leak(box<U, A>&&);
+
+    template<is_object U, allocator A>
+    friend class box;
 };
 
 template<is_object T, allocator Allocator = DefaultAllocator, typename... Args>
-- 
cgit