diff --git a/immer/box.hpp b/immer/box.hpp index 92e02909..5b542ee2 100644 --- a/immer/box.hpp +++ b/immer/box.hpp @@ -12,9 +12,34 @@ #include #include +#include namespace immer { +namespace detail { +namespace arrays { +// Forward declarations for SFINAE +template +struct with_capacity; +template +struct no_capacity; +} // namespace arrays + +// Type trait to detect internal array implementation types +template +struct is_array_impl : std::false_type {}; + +template +struct is_array_impl> : std::true_type {}; + +template +struct is_array_impl> : std::true_type {}; + +template +inline constexpr bool is_array_impl_v = is_array_impl>::value; + +} // namespace detail + namespace detail { template @@ -77,7 +102,8 @@ class box */ template >::value>> + !std::is_same>::value && + !detail::is_array_impl_v>> box(Arg&& arg) : impl_{detail::make(std::forward(arg))} {