From 6afe70e09d7c521313730460c4e78f6ce293c14d Mon Sep 17 00:00:00 2001 From: Mohammad Nejati Date: Mon, 8 Sep 2025 16:25:30 +0000 Subject: [PATCH] detail::span_convertible handles void types fixes #202 --- include/boost/core/span.hpp | 12 ++++++++++-- test/span_constructible_test.cpp | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/include/boost/core/span.hpp b/include/boost/core/span.hpp index 3a602c25..8c4edde2 100644 --- a/include/boost/core/span.hpp +++ b/include/boost/core/span.hpp @@ -23,9 +23,17 @@ class span; namespace detail { +template +struct span_convertible +{ + static constexpr bool value = false; +}; + template -struct span_convertible { - static constexpr bool value = std::is_convertible::value; +struct span_convertible::value>::type> +{ + static constexpr bool value = true; }; template diff --git a/test/span_constructible_test.cpp b/test/span_constructible_test.cpp index fb54fc74..76eed4bc 100644 --- a/test/span_constructible_test.cpp +++ b/test/span_constructible_test.cpp @@ -25,6 +25,20 @@ struct range { } }; +struct buffer { + void* data() { + return 0; + } + + const void* data() const { + return 0; + } + + std::size_t size() const { + return 0; + } +}; + struct base { }; struct derived @@ -138,6 +152,10 @@ void test_range() const range&>)); BOOST_TEST_TRAIT_FALSE((std::is_constructible, range&>)); + BOOST_TEST_TRAIT_FALSE((std::is_constructible, + buffer>)); + BOOST_TEST_TRAIT_FALSE((std::is_constructible, + const buffer&>)); } void test_initializer_list()