From 940a7ebe9fcaf00af7d63ccfd08193cae6eca530 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 23 Apr 2024 14:29:33 +0200 Subject: [PATCH] fix make_array with is_convertible_without_narrowing --- STL_Extension/include/CGAL/array.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/STL_Extension/include/CGAL/array.h b/STL_Extension/include/CGAL/array.h index 98892c6257d..45da267b0ea 100644 --- a/STL_Extension/include/CGAL/array.h +++ b/STL_Extension/include/CGAL/array.h @@ -13,6 +13,7 @@ #define CGAL_ARRAY_H #include +#include #include #include @@ -63,7 +64,13 @@ constexpr std::array, sizeof...(Args) > make_array(Args&& ... args) { - return {{ std::forward(args)... }}; + using Target_type = Make_array_element_type_t; + if constexpr ( (CGAL::is_convertible_without_narrowing_v, Target_type>&&...) ) + return {{ std::forward(args)... }}; + else { + std::array< Target_type, sizeof...(Args) > a = { { static_cast(args)... } }; + return a; + } } // Functor version