// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once // IWYU pragma: private, include "opentelemetry/nostd/span.h" #include "opentelemetry/version.h" // Standard library implementation requires at least C++17 compiler. // Older C++14 compilers may provide support for __has_include as a // conforming extension. #if defined __has_include # if __has_include() // Check for __cpp_{feature} # include # if defined(__cpp_lib_span) && __cplusplus > 201703L # define OPENTELEMETRY_HAVE_SPAN # endif # endif # if !defined(OPENTELEMETRY_HAVE_SPAN) # // Check for Visual Studio span # if defined(_MSVC_LANG) && _HAS_CXX20 # define OPENTELEMETRY_HAVE_SPAN # endif # // Check for other compiler span implementation # if !defined(_MSVC_LANG) && __has_include() && __cplusplus > 201703L // This works as long as compiler standard is set to C++20 # define OPENTELEMETRY_HAVE_SPAN # endif # endif # if !__has_include() # undef HAVE_GSL # endif #endif #if !defined(OPENTELEMETRY_HAVE_SPAN) # if defined(HAVE_GSL) # include // Guidelines Support Library provides an implementation of std::span # include OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { using gsl::dynamic_extent; template using span = gsl::span; } // namespace nostd OPENTELEMETRY_END_NAMESPACE # define OPENTELEMETRY_HAVE_SPAN # else // No `gsl::span`, no `std::span`, fallback to `nostd::span` # endif #else // OPENTELEMETRY_HAVE_SPAN // Using std::span (https://wg21.link/P0122R7) from Standard Library available in C++20 : // - GCC libstdc++ 10+ // - Clang libc++ 7 // - MSVC Standard Library 19.26* // - Apple Clang 10.0.0* # include # include OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { constexpr std::size_t dynamic_extent = (std::numeric_limits::max)(); template using span = std::span; } // namespace nostd OPENTELEMETRY_END_NAMESPACE #endif // if OPENTELEMETRY_HAVE_SPAN