<commit_before>// Copyright 2021 The IREE Authors
//
// Licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef IREE_BASE_INTERNAL_SPAN_H_
#define IREE_BASE_INTERNAL_SPAN_H_
#ifdef __cplusplus

#include <algorithm>
#include <cassert>
#include <cstddef>
#include <initializer_list>
#include <iterator>
#include <string>
#include <type_traits>
#include <utility>

// std::span is available starting in C++20.
// Prior to that we fall back to our simplified implementation below.
#if defined(__has_include)
#if __has_include(<span>) && __cplusplus >= 202002L
#define IREE_HAVE_STD_SPAN 1
#include <span>
#endif  // __has_include(<span>)
#endif  // __has_include

namespace iree {

#if defined(IREE_HAVE_STD_SPAN)

// Alias. Once we bump up our minimum C++ version we can drop this entire file.
template <typename T>
using span = std::span<T>;

#else

constexpr std::size_t dynamic_extent = std::numeric_limits<std::size_t>::max();

// A pared down version of std::span doing just enough for our uses in IREE.
// Most of the IREE code started using absl::Span which while close to std::span
// has some additional functionality of its own and is missing some from std.
// The benefit here is that means we only need to implement the intersection of
// the two as none of our code uses those newer std features.<commit_msg>missing #include <limits> (#7193)<commit_after>// Copyright 2021 The IREE Authors
//
// Licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef IREE_BASE_INTERNAL_SPAN_H_
#define IREE_BASE_INTERNAL_SPAN_H_
#ifdef __cplusplus

#include <algorithm>
#include <cassert>
#include <cstddef>
#include <initializer_list>
#include <iterator>
#include <string>
#include <type_traits>
#include <utility>

// std::span is available starting in C++20.
// Prior to that we fall back to our simplified implementation below.
#if defined(__has_include)
#if __has_include(<span>) && __cplusplus >= 202002L
#define IREE_HAVE_STD_SPAN 1
#include <span>
#endif  // __has_include(<span>)
#endif  // __has_include

#ifndef IREE_HAVE_STD_SPAN
#include <limits>
#endif

namespace iree {

#if defined(IREE_HAVE_STD_SPAN)

// Alias. Once we bump up our minimum C++ version we can drop this entire file.
template <typename T>
using span = std::span<T>;

#else

constexpr std::size_t dynamic_extent = std::numeric_limits<std::size_t>::max();

// A pared down version of std::span doing just enough for our uses in IREE.
// Most of the IREE code started using absl::Span which while close to std::span
// has some additional functionality of its own and is missing some from std.
// The benefit here is that means we only need to implement the intersection of
// the two as none of our code uses those newer std features.
{'fraction_non_alphanumeric': 0.0997648639570037, 'fraction_numerical': 0.012764528048370843, 'mean_word_length': 4.771317829457364, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 35, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5799124', 'n_tokens_mistral': 966, 'n_tokens_neox': 921, 'n_words': 355}