NVIDIA DeepStream SDK API Reference

9.2 Release
9.2/includes/opentelemetry/std/span.h
Go to the documentation of this file.
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3 
4 #pragma once
5 
6 // IWYU pragma: private, include "opentelemetry/nostd/span.h"
7 
8 #include "opentelemetry/version.h"
9 
10 // Standard library implementation requires at least C++17 compiler.
11 // Older C++14 compilers may provide support for __has_include as a
12 // conforming extension.
13 #if defined __has_include
14 # if __has_include(<version>) // Check for __cpp_{feature}
15 # include <version>
16 # if defined(__cpp_lib_span) && __cplusplus > 201703L
17 # define OPENTELEMETRY_HAVE_SPAN
18 # endif
19 # endif
20 # if !defined(OPENTELEMETRY_HAVE_SPAN)
21 # // Check for Visual Studio span
22 # if defined(_MSVC_LANG) && _HAS_CXX20
23 # define OPENTELEMETRY_HAVE_SPAN
24 # endif
25 # // Check for other compiler span implementation
26 # if !defined(_MSVC_LANG) && __has_include(<span>) && __cplusplus > 201703L
27 // This works as long as compiler standard is set to C++20
28 # define OPENTELEMETRY_HAVE_SPAN
29 # endif
30 # endif
31 # if !__has_include(<gsl/gsl>)
32 # undef HAVE_GSL
33 # endif
34 #endif
35 
36 #if !defined(OPENTELEMETRY_HAVE_SPAN)
37 # if defined(HAVE_GSL)
38 # include <type_traits>
39 // Guidelines Support Library provides an implementation of std::span
40 # include <gsl/gsl>
42 namespace nostd
43 {
45 template <class ElementType, std::size_t Extent = gsl::dynamic_extent>
46 using span = gsl::span<ElementType, Extent>;
47 } // namespace nostd
49 # define OPENTELEMETRY_HAVE_SPAN
50 # else
51 // No `gsl::span`, no `std::span`, fallback to `nostd::span`
52 # endif
53 
54 #else // OPENTELEMETRY_HAVE_SPAN
55 // Using std::span (https://wg21.link/P0122R7) from Standard Library available in C++20 :
56 // - GCC libstdc++ 10+
57 // - Clang libc++ 7
58 // - MSVC Standard Library 19.26*
59 // - Apple Clang 10.0.0*
60 # include <limits>
61 # include <span>
63 namespace nostd
64 {
65 constexpr std::size_t dynamic_extent = (std::numeric_limits<std::size_t>::max)();
66 
67 template <class ElementType, std::size_t Extent = nostd::dynamic_extent>
68 using span = std::span<ElementType, Extent>;
69 } // namespace nostd
71 #endif // if OPENTELEMETRY_HAVE_SPAN
nostd
Definition: includes/opentelemetry/nostd/function_ref.h:14
OPENTELEMETRY_BEGIN_NAMESPACE
#define OPENTELEMETRY_BEGIN_NAMESPACE
Definition: includes/opentelemetry/version.h:21
max
int max(int a, int b)
Compute the component-wise maximum.
Definition: sources/libs/nvmultiobjecttracker/include/modules/cuDCFv2/helper_math.h:60
OPENTELEMETRY_END_NAMESPACE
#define OPENTELEMETRY_END_NAMESPACE
Definition: includes/opentelemetry/version.h:24
nostd::dynamic_extent
constexpr size_t dynamic_extent
Definition: includes/opentelemetry/nostd/span.h:48