Utils: Use span with initializer list

Make span even more useful as it can takes initializer lists.

void foo(Utils::span<float> x);

foo({1.2, 2.3});

Change-Id: Iaebbcad9dd875fbe0535b717941c6e0fc837303d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Marco Bubke
2025-04-06 01:10:35 +02:00
parent ff5ca5f5b4
commit d41775ecd7

View File

@@ -6,9 +6,8 @@
#include <qcompilerdetection.h> #include <qcompilerdetection.h>
// The (Apple) Clang implementation of span is incomplete until LLVM 15 / Xcode 14.3 / macOS 13 // The (Apple) Clang implementation of span is incomplete until LLVM 15 / Xcode 14.3 / macOS 13
#if __cplusplus >= 202002L \ #ifdef __cpp_lib_span_initializer_list
&& !(defined(__apple_build_version__) && __apple_build_version__ < 14030022) # include <span>
#include <span>
namespace Utils { namespace Utils {
using std::as_bytes; using std::as_bytes;
@@ -27,9 +26,9 @@ QT_WARNING_PUSH
// disable automatic usage of std::span in span-lite // disable automatic usage of std::span in span-lite
// since we make that decision ourselves at the top of this header // since we make that decision ourselves at the top of this header
#define span_CONFIG_SELECT_SPAN span_SPAN_NONSTD # define span_CONFIG_SELECT_SPAN span_SPAN_NONSTD
# define span_FEATURE_WITH_INITIALIZER_LIST_P2447 1
#include <3rdparty/span/span.hpp> # include <3rdparty/span/span.hpp>
namespace Utils { namespace Utils {
using namespace nonstd; using namespace nonstd;