Enable span-lite's `make_span()` function, which exists to compensate
for the lack of class template argument deduction in C++ pre 17. This
allows creating spans without being too verbose. This is not a standard
function, but the day we switch to C++ 17 and want to use `std::span`,
we can just replace all uses of `make_span()` with calls to
`std::span`'s constructor.
Make one version of `nonstd::make_span` (expected to be used in an
upcoming patch) available as `bt2c::makeSpan()`.
Change-Id: Ie28c1884d2c03c38a4b839096afae887fa54cc04
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12117
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
cpp-common/bt2c/prio-heap.hpp \
cpp-common/bt2c/read-fixed-len-int.hpp \
cpp-common/bt2c/safe-ops.hpp \
cpp-common/bt2c/prio-heap.hpp \
cpp-common/bt2c/read-fixed-len-int.hpp \
cpp-common/bt2c/safe-ops.hpp \
+ cpp-common/bt2c/span.hpp \
cpp-common/bt2c/std-int.hpp \
cpp-common/bt2c/type-traits.hpp \
cpp-common/bt2c/uuid.hpp \
cpp-common/bt2c/std-int.hpp \
cpp-common/bt2c/type-traits.hpp \
cpp-common/bt2c/uuid.hpp \
--- /dev/null
+/*
+ * Copyright (c) 2024 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef BABELTRACE_CPP_COMMON_BT2C_SPAN_HPP
+#define BABELTRACE_CPP_COMMON_BT2C_SPAN_HPP
+
+#include "cpp-common/bt2s/span.hpp"
+
+namespace bt2c {
+
+template <class T>
+inline constexpr bt2s::span<T> makeSpan(T * const ptr, const size_t count) noexcept
+{
+ return nonstd::make_span(ptr, count);
+}
+
+} /* namespace bt2c */
+
+#endif /* BABELTRACE_CPP_COMMON_BT2C_SPAN_HPP */
#ifndef BABELTRACE_CPP_COMMON_BT2S_SPAN_HPP
#define BABELTRACE_CPP_COMMON_BT2S_SPAN_HPP
#ifndef BABELTRACE_CPP_COMMON_BT2S_SPAN_HPP
#define BABELTRACE_CPP_COMMON_BT2S_SPAN_HPP
-#include "cpp-common/vendor/span-lite/span.hpp"
+#define span_FEATURE_MAKE_SPAN 1
+
+#include "cpp-common/vendor/span-lite/span.hpp" /* IWYU pragma: export */