<commit_before>#pragma once

#include <agency/detail/config.hpp>
#include <agency/experimental/array.hpp>
#include <agency/experimental/ranges/range_traits.hpp>
#include <cstddef>

namespace agency
{
namespace experimental
{


constexpr std::ptrdiff_t dynamic_extent = -1;


namespace detail
{


template<std::ptrdiff_t Extent>
class span_base
{
  public:
    __AGENCY_ANNOTATION
    span_base(std::ptrdiff_t)
    {
    }

    __AGENCY_ANNOTATION
    std::ptrdiff_t size() const
    {
      return Extent;
    }
};


template<>
class span_base<dynamic_extent>
{
  public:
    __AGENCY_ANNOTATION
    span_base(std::ptrdiff_t size)
      : size_(size)
    {
    }

    __AGENCY_ANNOTATION
    std::ptrdiff_t size() const
    {
      return size_;
    }

  private:
    std::ptrdiff_t size_;
};


} // end detail


// see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0122r1.pdf
template<class ElementType, std::ptrdiff_t Extent = dynamic_extent>
class span : private detail::span_base<Extent>
{
  private:
    using super_t = detail::span_base<Extent>;

  public:
    using element_type = ElementType;
    using index_type = std::ptrdiff_t;
    using pointer = element_type*;
    using reference = element_type&;
    using iterator = pointer;

    constexpr static index_type extent = Extent;

    __AGENCY_ANNOTATION
    span() : span(nullptr) {}

    __AGENCY_ANNOTATION
    explicit span(std::nullptr_t) : span(nullptr, 0) {}

    __AGENCY_ANNOTATION
    span(pointer ptr, index_type count)
      : super_t(ptr ? count : 0),
        data_(ptr)
    {}

    __AGENCY_ANNOTATION
    span(pointer first, pointer last) : span(first, last - first) {}

    template<size_t N>
    __AGENCY_ANNOTATION
    span(element_type (&arr)[N]) : span(arr, N) {}

    template<size_t N>
    __AGENCY_ANNOTATION
    span(array<typename std::remove_const<element_type>::type,N>& arr) : span(arr, N) {}

    template<size_t N>
    __AGENCY_ANNOTATION
    span(const array<typename std::remove_const<element_type>::type,N>& arr) : span(arr, N) {}

    // XXX should require iterator contiguity, but that requires contiguous_iterator_tag
    __agency_exec_check_disable__
    template<class Container,
             class BeginPointer = decltype(&*std::declval<Container>().begin()),
             class EndPointer = decltype(&*std::declval<Container>().end()),
             class = typename std::enable_if<
               std::is_convertible<BeginPointer,pointer>::value &&<commit_msg>Disambiguate one of span's constructors<commit_after>#pragma once

#include <agency/detail/config.hpp>
#include <agency/experimental/array.hpp>
#include <agency/experimental/ranges/range_traits.hpp>
#include <cstddef>

namespace agency
{
namespace experimental
{


constexpr std::ptrdiff_t dynamic_extent = -1;


namespace detail
{


template<std::ptrdiff_t Extent>
class span_base
{
  public:
    __AGENCY_ANNOTATION
    span_base(std::ptrdiff_t)
    {
    }

    __AGENCY_ANNOTATION
    std::ptrdiff_t size() const
    {
      return Extent;
    }
};


template<>
class span_base<dynamic_extent>
{
  public:
    __AGENCY_ANNOTATION
    span_base(std::ptrdiff_t size)
      : size_(size)
    {
    }

    __AGENCY_ANNOTATION
    std::ptrdiff_t size() const
    {
      return size_;
    }

  private:
    std::ptrdiff_t size_;
};


} // end detail


// see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0122r1.pdf
template<class ElementType, std::ptrdiff_t Extent = dynamic_extent>
class span : private detail::span_base<Extent>
{
  private:
    using super_t = detail::span_base<Extent>;

  public:
    using element_type = ElementType;
    using index_type = std::ptrdiff_t;
    using pointer = element_type*;
    using reference = element_type&;
    using iterator = pointer;

    constexpr static index_type extent = Extent;

    __AGENCY_ANNOTATION
    span() : span(nullptr) {}

    __AGENCY_ANNOTATION
    explicit span(std::nullptr_t) : span(nullptr, index_type{0}) {}

    __AGENCY_ANNOTATION
    span(pointer ptr, index_type count)
      : super_t(ptr ? count : 0),
        data_(ptr)
    {}

    __AGENCY_ANNOTATION
    span(pointer first, pointer last) : span(first, last - first) {}

    template<size_t N>
    __AGENCY_ANNOTATION
    span(element_type (&arr)[N]) : span(arr, N) {}

    template<size_t N>
    __AGENCY_ANNOTATION
    span(array<typename std::remove_const<element_type>::type,N>& arr) : span(arr, N) {}

    template<size_t N>
    __AGENCY_ANNOTATION
    span(const array<typename std::remove_const<element_type>::type,N>& arr) : span(arr, N) {}

    // XXX should require iterator contiguity, but that requires contiguous_iterator_tag
    __agency_exec_check_disable__
    template<class Container,
             class BeginPointer = decltype(&*std::declval<Container>().begin()),
             class EndPointer = decltype(&*std::declval<Container>().end()),
             class = typename std::enable_if<
               std::is_convertible<BeginPointer,pointer>::value &&
{'fraction_non_alphanumeric': 0.11336276083467095, 'fraction_numerical': 0.006821829855537721, 'mean_word_length': 3.544211485870556, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4011324', 'n_tokens_mistral': 1741, 'n_tokens_neox': 1666, 'n_words': 322}