1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
6 #include "opentelemetry/version.h"
8 // Standard library implementation requires at least C++17 compiler.
9 // Older C++14 compilers may provide support for __has_include as a
10 // conforming extension.
11 #if defined __has_include
12 # if __has_include(<version>) // Check for __cpp_{feature}
14 # if defined(__cpp_lib_span) && __cplusplus > 201703L
18 # if !defined(HAVE_SPAN)
19 # // Check for Visual Studio span
20 # if defined(_MSVC_LANG) && _HAS_CXX20
23 # // Check for other compiler span implementation
24 # if !defined(_MSVC_LANG) && __has_include(<span>) && __cplusplus > 201703L
25 // This works as long as compiler standard is set to C++20
29 # if !__has_include(<gsl/gsl>)
34 #if !defined(HAVE_SPAN)
35 # if defined(HAVE_GSL)
36 # include <type_traits>
37 // Guidelines Support Library provides an implementation of std::span
39 OPENTELEMETRY_BEGIN_NAMESPACE
42 using gsl::dynamic_extent
;
43 template <class ElementType
, std::size_t Extent
= gsl::dynamic_extent
>
44 using span
= gsl::span
<ElementType
, Extent
>;
46 OPENTELEMETRY_END_NAMESPACE
49 // No `gsl::span`, no `std::span`, fallback to `nostd::span`
53 // Using std::span (https://wg21.link/P0122R7) from Standard Library available in C++20 :
54 // - GCC libstdc++ 10+
56 // - MSVC Standard Library 19.26*
57 // - Apple Clang 10.0.0*
60 OPENTELEMETRY_BEGIN_NAMESPACE
63 constexpr std::size_t dynamic_extent
= (std::numeric_limits
<std::size_t>::max());
65 template <class ElementType
, std::size_t Extent
= nostd::dynamic_extent
>
66 using span
= std::span
<ElementType
, Extent
>;
68 OPENTELEMETRY_END_NAMESPACE
69 #endif // of HAVE_SPAN