|
| 1 | +// include/beman/optional26/detail/stl_interfaces/fwd.hpp -*-C++-*- |
| 2 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | + |
| 4 | +// Copyright (C) 2019 T. Zachary Laine |
| 5 | +// |
| 6 | +// Distributed under the Boost Software License, Version 1.0. (See |
| 7 | +// accompanying file LICENSE_1_0.txt or copy at |
| 8 | +// http://www.boost.org/LICENSE_1_0.txt) |
| 9 | +#ifndef BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_FWD_HPP |
| 10 | +#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_FWD_HPP |
| 11 | + |
| 12 | +#include <beman/iterator_interface26/detail/stl_interfaces/config.hpp> |
| 13 | + |
| 14 | +#if BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_CONCEPTS |
| 15 | +#include <ranges> |
| 16 | +#endif |
| 17 | +#if defined(__cpp_lib_three_way_comparison) |
| 18 | +#include <compare> |
| 19 | +#endif |
| 20 | + |
| 21 | +#ifndef BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_DOXYGEN |
| 22 | + |
| 23 | +#if defined(_MSC_VER) || defined(__GNUC__) && __GNUC__ < 8 |
| 24 | +#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NO_HIDDEN_FRIEND_CONSTEXPR |
| 25 | +#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR |
| 26 | +#else |
| 27 | +#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR constexpr |
| 28 | +#endif |
| 29 | + |
| 30 | +#if defined(__GNUC__) && __GNUC__ < 9 |
| 31 | +#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_CONCEPT concept bool |
| 32 | +#else |
| 33 | +#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_CONCEPT concept |
| 34 | +#endif |
| 35 | + |
| 36 | +#endif |
| 37 | + |
| 38 | +namespace beman::iterator_interface26::detail { |
| 39 | +namespace stl_interfaces { |
| 40 | + |
| 41 | +/** An enumeration used to indicate whether the underlying data have a |
| 42 | + contiguous or discontiguous layout when instantiating `view_interface` |
| 43 | + and `sequence_container_interface`. */ |
| 44 | +enum class element_layout : bool { discontiguous = false, contiguous = true }; |
| 45 | + |
| 46 | +BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V1 { |
| 47 | + |
| 48 | + namespace v1_dtl { |
| 49 | + template <typename... T> |
| 50 | + using void_t = void; |
| 51 | + |
| 52 | + template <typename Iter> |
| 53 | + using iter_difference_t = typename std::iterator_traits<Iter>::difference_type; |
| 54 | + |
| 55 | + template <typename Range, typename = void> |
| 56 | + struct iterator; |
| 57 | + template <typename Range> |
| 58 | + struct iterator<Range, void_t<decltype(std::declval<Range&>().begin())>> { |
| 59 | + using type = decltype(std::declval<Range&>().begin()); |
| 60 | + }; |
| 61 | + template <typename Range> |
| 62 | + using iterator_t = typename iterator<Range>::type; |
| 63 | + |
| 64 | + template <typename Range, typename = void> |
| 65 | + struct sentinel; |
| 66 | + template <typename Range> |
| 67 | + struct sentinel<Range, void_t<decltype(std::declval<Range&>().end())>> { |
| 68 | + using type = decltype(std::declval<Range&>().end()); |
| 69 | + }; |
| 70 | + template <typename Range> |
| 71 | + using sentinel_t = typename sentinel<Range>::type; |
| 72 | + |
| 73 | + template <typename Range> |
| 74 | + using range_difference_t = iter_difference_t<iterator_t<Range>>; |
| 75 | + |
| 76 | + template <typename Range> |
| 77 | + using common_range = std::is_same<iterator_t<Range>, sentinel_t<Range>>; |
| 78 | + |
| 79 | + template <typename Range, typename = void> |
| 80 | + struct decrementable_sentinel : std::false_type {}; |
| 81 | + template <typename Range> |
| 82 | + struct decrementable_sentinel<Range, void_t<decltype(--std::declval<sentinel_t<Range>&>())>> : std::true_type {}; |
| 83 | + } // namespace v1_dtl |
| 84 | +} |
| 85 | +} // namespace stl_interfaces |
| 86 | +} // namespace beman::optional26::detail |
| 87 | + |
| 88 | +#endif |
0 commit comments