// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #if defined(OPENTELEMETRY_STL_VERSION) # if OPENTELEMETRY_STL_VERSION >= 2014 # include "opentelemetry/std/utility.h" # define OPENTELEMETRY_HAVE_STD_UTILITY # endif #endif #if !defined(OPENTELEMETRY_HAVE_STD_UTILITY) # include # include # include # include "opentelemetry/nostd/detail/decay.h" // IWYU pragma: export # include "opentelemetry/nostd/detail/invoke.h" // IWYU pragma: export # include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { /** * Back port of std::data * * See https://en.cppreference.com/w/cpp/iterator/data */ template auto data(C &c) noexcept(noexcept(c.data())) -> decltype(c.data()) { return c.data(); } template auto data(const C &c) noexcept(noexcept(c.data())) -> decltype(c.data()) { return c.data(); } template T *data(T (&array)[N]) noexcept { return array; } template const E *data(std::initializer_list list) noexcept { return list.begin(); } /** * Back port of std::size * * See https://en.cppreference.com/w/cpp/iterator/size */ template auto size(const C &c) noexcept(noexcept(c.size())) -> decltype(c.size()) { return c.size(); } template size_t size(T (& /* array */)[N]) noexcept { return N; } /** * Back port of std::bool_constant */ template using bool_constant = std::integral_constant; /** * Back port of std::integer_sequence */ template struct integer_sequence { using value_type = T; static constexpr std::size_t size() noexcept { return sizeof...(Is); } }; /** * Back port of std::index_sequence */ template using index_sequence = integer_sequence; /** * Back port of std::make_index_sequence */ namespace detail { template struct index_sequence_push_back {}; template struct index_sequence_push_back, I> { using type = index_sequence; }; template using index_sequence_push_back_t = typename index_sequence_push_back::type; template struct make_index_sequence_impl { using type = index_sequence_push_back_t::type, N - 1>; }; template <> struct make_index_sequence_impl<0> { using type = index_sequence<>; }; } // namespace detail template using make_index_sequence = typename detail::make_index_sequence_impl::type; /** * Back port of std::index_sequence_for */ template using index_sequence_for = make_index_sequence; /** * Back port of std::in_place_t */ struct in_place_t { explicit in_place_t() = default; }; /** * Back port of std::in_place_index_t */ template struct in_place_index_t { explicit in_place_index_t() = default; }; /** * Back port of std::in_place_type_t */ template struct in_place_type_t { explicit in_place_type_t() = default; }; } // namespace nostd OPENTELEMETRY_END_NAMESPACE #endif /* OPENTELEMETRY_HAVE_STD_UTILITY */