From 397ca900ab84677a786f8bfd2d6ffa812b7bdddf Mon Sep 17 00:00:00 2001 From: John Colvin Date: Fri, 7 Jan 2022 14:24:34 -0500 Subject: [PATCH] Add std dir to includes (for ranges v3) Forgot to do this when I originally added the ranges v3 lib to windows --- .../include/std/detail/associated_types.hpp | 314 ++++++++++++++++++ windows/include/std/iterator | 278 ++++++++++++++++ 2 files changed, 592 insertions(+) create mode 100644 windows/include/std/detail/associated_types.hpp create mode 100644 windows/include/std/iterator diff --git a/windows/include/std/detail/associated_types.hpp b/windows/include/std/detail/associated_types.hpp new file mode 100644 index 000000000..449a3f91c --- /dev/null +++ b/windows/include/std/detail/associated_types.hpp @@ -0,0 +1,314 @@ +// Range v3 library +// +// Copyright Eric Niebler 2013-2014, 2016-present +// Copyright Casey Carter 2016 +// +// Use, modification and distribution is subject to the +// Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// Project home: https://github.com/ericniebler/range-v3 +// + +#ifndef RANGES_V3_STD_DETAIL_ASSOCIATED_TYPES_HPP +#define RANGES_V3_STD_DETAIL_ASSOCIATED_TYPES_HPP + +#include +#include + +#include + +#include + +namespace ranges +{ + /// \addtogroup group-iterator + /// @{ + + //////////////////////////////////////////////////////////////////////////////////////// + /// \cond + namespace detail + { + struct nil_ + {}; + + template + using always_ = T; + +#if defined(_MSC_VER) && !defined(__clang__) && !defined(__EDG__) + // MSVC laughs at your silly micro-optimizations and implements + // conditional_t, enable_if_t, is_object_v, and is_integral_v in the + // compiler. + using std::conditional_t; + using std::enable_if; + using std::enable_if_t; +#else // ^^^ MSVC / not MSVC vvv + template + struct _cond + { + template + using invoke = U; + }; + template<> + struct _cond + { + template + using invoke = T; + }; + template + using conditional_t = typename _cond::template invoke; + + template + struct enable_if + {}; + template<> + struct enable_if + { + template + using invoke = T; + }; + template + using enable_if_t = typename enable_if::template invoke; + +#ifndef __clang__ + // NB: insufficient for MSVC, which (non-conformingly) allows function + // pointers to implicitly convert to void*. + void is_objptr_(void const volatile *); + + // std::is_object, optimized for compile time. + template + constexpr bool is_object_(long) + { + return false; + } + template + constexpr bool is_object_(int, T * (*q)(T &) = nullptr, T * p = nullptr, + decltype(detail::is_objptr_(q(*p))) * = nullptr) + { + return (void)p, (void)q, true; + } +#endif // !__clang__ + + template + constexpr bool is_integral_(...) + { + return false; + } + template + constexpr bool is_integral_(long) + { + return true; + } +#if defined(__cpp_nontype_template_parameter_class) && \ + __cpp_nontype_template_parameter_class > 0 + template + constexpr bool is_integral_(int, int T::* = nullptr) + { + return false; + } +#endif +#endif // detect MSVC + + template + struct with_difference_type_ + { + using difference_type = T; + }; + + template + using difference_result_t = + decltype(std::declval() - std::declval()); + + template + struct incrementable_traits_2_ + {}; + + template + struct incrementable_traits_2_< + T, +#if defined(_MSC_VER) && !defined(__clang__) && !defined(__EDG__) + std::enable_if_t>>> +#elif defined(RANGES_WORKAROUND_GCC_91923) + std::enable_if_t>::value>> +#else + always_>(0)]>> +#endif // detect MSVC + { + using difference_type = std::make_signed_t>; + }; + + template + struct incrementable_traits_1_ : incrementable_traits_2_ + {}; + + template + struct incrementable_traits_1_ +#ifdef __clang__ + : conditional_t<__is_object(T), with_difference_type_, nil_> +#elif defined(_MSC_VER) && !defined(__EDG__) + : conditional_t, with_difference_type_, nil_> +#else // ^^^ MSVC / not MSVC vvv + : conditional_t(0), with_difference_type_, nil_> +#endif // detect MSVC + {}; + + template + struct incrementable_traits_1_> + { + using difference_type = typename T::difference_type; + }; + } // namespace detail + /// \endcond + + template + struct incrementable_traits : detail::incrementable_traits_1_ + {}; + + template + struct incrementable_traits : incrementable_traits + {}; + + /// \cond + namespace detail + { +#ifdef __clang__ + template +#elif defined(_MSC_VER) && !defined(__EDG__) + template> +#else // ^^^ MSVC / not MSVC vvv + template(0)> +#endif // detect MSVC + struct with_value_type_ + {}; + template + struct with_value_type_ + { + using value_type = T; + }; + template + struct with_value_type_ + { + using value_type = T; + }; + template + struct with_value_type_ + { + using value_type = T; + }; + template + struct with_value_type_ + { + using value_type = T; + }; + template + struct readable_traits_2_ + {}; + template + struct readable_traits_2_> + : with_value_type_ + {}; + template + struct readable_traits_1_ : readable_traits_2_ + {}; + template + struct readable_traits_1_ : with_value_type_ + {}; + template + struct readable_traits_1_ : with_value_type_ + {}; + template + struct readable_traits_1_ : detail::with_value_type_ + {}; + template + struct readable_traits_1_> + : with_value_type_ + {}; + } // namespace detail + /// \endcond + + //////////////////////////////////////////////////////////////////////////////////////// + // Not to spec: + // * For class types with both member value_type and element_type, value_type is + // preferred (see ericniebler/stl2#299). + template + struct indirectly_readable_traits : detail::readable_traits_1_ + {}; + + template + struct indirectly_readable_traits : indirectly_readable_traits + {}; + + /// \cond + namespace detail + { + template + struct std_output_iterator_traits + { + using iterator_category = std::output_iterator_tag; + using difference_type = D; + using value_type = void; + using reference = void; + using pointer = void; + }; + + // For testing whether a particular instantiation of std::iterator_traits + // is user-specified or not. +#if defined(_MSVC_STL_UPDATE) && defined(__cpp_lib_concepts) && _MSVC_STL_UPDATE >= 201908L + template + inline constexpr bool is_std_iterator_traits_specialized_v = + !std::_Is_from_primary>; +#else +#if defined(__GLIBCXX__) + template + char (&is_std_iterator_traits_specialized_impl_(std::__iterator_traits *))[2]; + template + char is_std_iterator_traits_specialized_impl_(void *); +#elif defined(_LIBCPP_VERSION) + // In older versions of libc++, the base template inherits from std::__iterator_traits. + template class IteratorTraitsBase, typename I, bool B> + char (&libcpp_iterator_traits_base_impl(IteratorTraitsBase *))[2]; + template class IteratorTraitsBase, typename I> + char libcpp_iterator_traits_base_impl(void *); + + // In newer versions, the base template has only one template parameter and provides the + // __primary_template typedef which aliases the iterator_traits specialization. + template class, typename I> + char (&libcpp_iterator_traits_base_impl(typename std::iterator_traits::__primary_template *))[2]; + template class, typename I> + char libcpp_iterator_traits_base_impl(void *); + + template + auto is_std_iterator_traits_specialized_impl_(std::iterator_traits* traits) + -> decltype(libcpp_iterator_traits_base_impl(traits)); +#elif defined(_MSVC_STL_VERSION) + template + char (&is_std_iterator_traits_specialized_impl_( + std::_Iterator_traits_base *))[2]; + template + char is_std_iterator_traits_specialized_impl_(void *); +#else + template + char (&is_std_iterator_traits_specialized_impl_(void *))[2]; +#endif + template + char (&is_std_iterator_traits_specialized_impl_(std::iterator_traits *))[2]; + + template + RANGES_INLINE_VAR constexpr bool is_std_iterator_traits_specialized_v = + 1 == sizeof(is_std_iterator_traits_specialized_impl_( + static_cast *>(nullptr))); +#endif + // The standard iterator_traits specialization(s) do not count + // as user-specialized. This will no longer be necessary in C++20. + // This helps with `T volatile*` and `void *`. + template + RANGES_INLINE_VAR constexpr bool is_std_iterator_traits_specialized_v = + false; + } // namespace detail + /// \endcond +} // namespace ranges + +#include + +#endif diff --git a/windows/include/std/iterator b/windows/include/std/iterator new file mode 100644 index 000000000..23d5cf36d --- /dev/null +++ b/windows/include/std/iterator @@ -0,0 +1,278 @@ +// Range v3 library +// +// Copyright Eric Niebler 2018-present +// +// Use, modification and distribution is subject to the +// Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// Project home: https://github.com/ericniebler/range-v3 +// + +#ifndef RANGES_V3_STD_ITERATOR +#define RANGES_V3_STD_ITERATOR + +#if defined(__GNUC__) +#include_next +#elif defined(_MSC_VER) +#include <../include/iterator> // HACKHACK +#else +#error "Cannot use range-v3 STL deep integration on this platform." +#endif + +#if RANGES_DEEP_STL_INTEGRATION + +#include +#include + +#include + +namespace ranges +{ + template + struct incrementable_traits; + + template + struct indirectly_readable_traits; + + /// \cond + namespace detail + { + template + typename incrementable_traits::difference_type cpp17_difference_type_(int); + template + void cpp17_difference_type_(long); + + template + typename I::pointer cpp17_pointer_type_(int); + template + auto cpp17_pointer_type_(long, I *pi = nullptr) -> decltype(pi->operator->()); + template + void cpp17_pointer_type_(...); + + template + typename I::reference cpp17_reference_type_(int); + template + auto cpp17_reference_type_(long, I *pi = nullptr) -> decltype(**pi); + + template + auto cpp17_iterator_category_4_(long) + { + return std::bidirectional_iterator_tag{}; + } + // Satisfies Cpp17RandomAccessIterator? + template + auto cpp17_iterator_category_4_( + int, + I *pi = nullptr, + typename incrementable_traits::difference_type d = 0, + always_< + void, + int[RANGES_IS_SAME(decltype(*pi += d), I &)], + int[RANGES_IS_SAME(decltype(*pi -= d), I &)], + int[RANGES_IS_SAME(decltype(*pi + d), I)], + int[RANGES_IS_SAME(decltype(*pi - d), I)], + int[RANGES_IS_SAME(decltype(d + *pi), I)], + int[RANGES_IS_SAME(decltype(*pi - *pi), decltype(d))], + int[RANGES_IS_SAME(decltype((*pi)[d]), decltype(**pi))], + decltype(*pi < *pi ? true : false), + decltype(*pi > *pi ? true : false), + decltype(*pi <= *pi ? true : false), + decltype(*pi >= *pi ? true : false) + > * = nullptr) + { + return std::random_access_iterator_tag{}; + } + + template + auto cpp17_iterator_category_3_(long) + { + return std::forward_iterator_tag{}; + } + // Satisfies Cpp17BidirectionalIterator? + template + auto cpp17_iterator_category_3_( + int, + I *pi = nullptr, + void (*fn)(I const &) = nullptr, + always_< + void, + decltype(fn((*pi)--)), // i-- convertible to I const & + int[RANGES_IS_SAME(decltype(--*pi), I &)], // --i has type I & + // *i has the same type as *i-- + int[RANGES_IS_SAME(decltype(**pi), decltype(*(*pi)--))] + > * = nullptr) + { + return cpp17_iterator_category_4_(0); + } + + template + auto cpp17_iterator_category_2_(long) + { + return std::input_iterator_tag{}; + } + // Satisfies Cpp17ForwardIterator? + template + auto cpp17_iterator_category_2_( + int, + I *pi = nullptr, + void (*fn)(I const &) = nullptr, + typename indirectly_readable_traits::value_type *pv = nullptr, + typename indirectly_readable_traits::value_type const *pcv = nullptr, + always_< + void, + decltype(I{}), // Default constructible + decltype(fn((*pi)++)), // i++ convertible to I const & + // *i has the same type as *i++ + int[RANGES_IS_SAME(decltype(**pi), decltype(*(*pi)++))], + // *i is a real reference to value_type +#ifdef RANGES_WORKAROUND_MSVC_793042 + enable_if_t::value_type &&) || + RANGES_IS_SAME(decltype(**pi), typename indirectly_readable_traits::value_type const &&)> +#else // ^^^ workaround / no workaround vvv + int[RANGES_IS_SAME(decltype(**pi), decltype(*pv)) || + RANGES_IS_SAME(decltype(**pi), decltype(*pcv)) || + RANGES_IS_SAME(decltype(**pi), typename indirectly_readable_traits::value_type &&) || + RANGES_IS_SAME(decltype(**pi), typename indirectly_readable_traits::value_type const &&)] +#endif // RANGES_WORKAROUND_MSVC_793042 + > * = nullptr) + { + return cpp17_iterator_category_3_(0); + } + + template + using cpp17_readable_iterator_category_t = + decltype(detail::cpp17_iterator_category_2_(0)); + + template + auto cpp17_iterator_category_(long) + { + return cpp17_iterator_category_2_(0); + } + // Explicitly declares its category? + template + typename I::iterator_category cpp17_iterator_category_(int) + { + return {}; + } + + template + auto std_iterator_traits_impl_2_(long) + { + return std_output_iterator_traits< + decltype(detail::cpp17_difference_type_(0))>{}; + } + // Satisfies Cpp17InputIterator? + template + auto std_iterator_traits_impl_2_( + int, + I *pi = nullptr, + typename incrementable_traits::difference_type d = 0, + typename indirectly_readable_traits::value_type const *pcv = nullptr, + always_< + void, + int[decltype(d)(-1) < decltype(d)(0)], // signed difference type + decltype(decltype(*pcv)(**pi)), // sensible reference/value type + decltype(decltype(*pcv)(*(*pi)++)), // sensible post-increment result + decltype(*pi == *pi ? true : false), // equality comparable + decltype(*pi != *pi ? true : false) // " " + > * = nullptr) + { + using D = typename incrementable_traits::difference_type; + struct yes_traits + { + using difference_type = D; + using value_type = typename indirectly_readable_traits::value_type; + using reference = decltype(cpp17_reference_type_(0)); + using pointer = decltype(cpp17_pointer_type_(0)); + using iterator_category = decltype(cpp17_iterator_category_(0)); + }; + struct no_traits + {}; + return conditional_t(0), yes_traits, no_traits>{}; + } + + template + nil_ std_iterator_traits_impl_(long) + { + return {}; + } + // Satisfies Cpp17Iterator? + template + auto std_iterator_traits_impl_( + int, + I *pi = nullptr, + void (*nv)(...) = nullptr, + always_< + void, + decltype(nv(**pi)), + int[RANGES_IS_SAME(decltype(++*pi), I &)], + decltype(nv(*(*pi)++)) + > * = nullptr) + { + return std_iterator_traits_impl_2_(0); + } + + template + constexpr bool has_iterator_typedefs_impl_( + int, + always_< + void, + typename T::difference_type, + typename T::value_type, + typename T::pointer, + typename T::reference, + typename T::iterator_category + > * = nullptr) + { + return true; + } + template + constexpr bool has_iterator_typedefs_impl_(long) + { + return false; + } + } + /// \endcond +} // namespace ranges + +// Hijack the primary std::iterator_traits template from each of the 3 major +// standard library implementations +RANGES_BEGIN_NAMESPACE_STD +RANGES_BEGIN_NAMESPACE_VERSION +#if defined(__GLIBCXX__) + template + struct __iterator_traits< + I, + ::ranges::detail::enable_if_t(0)>> + : decltype(::ranges::detail::std_iterator_traits_impl_(0)) + {}; +#elif defined(_LIBCPP_VERSION) + template + struct __iterator_traits // doesn't have I::iterator_category + : decltype(::ranges::detail::std_iterator_traits_impl_(0)) + {}; +#elif defined(_MSVC_STL_VERSION) + template + struct _Iterator_traits_base< + I, +#ifdef RANGES_WORKAROUND_MSVC_792338 + ::ranges::detail::enable_if_t(0)>{})::value>> +#else // ^^^ workaround / no workaround vvv + ::ranges::detail::enable_if_t(0)>> +#endif // RANGES_WORKAROUND_MSVC_792338 + : decltype(::ranges::detail::std_iterator_traits_impl_(0)) + {}; +#endif +RANGES_END_NAMESPACE_VERSION +RANGES_END_NAMESPACE_STD + +#include + +#endif // RANGES_DEEP_STL_INTEGRATION + +#endif // RANGES_V3_STD_ITERATOR