brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 5efd6c7 Raw
79 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++14, c++1710 11// ADL call with nested iterators of views should not look up base's view's12// namespace13 14#include <ranges>15#include <tuple>16 17#include "test_macros.h"18 19#ifndef TEST_HAS_NO_LOCALIZATION20#include <istream>21#endif22namespace adl {23 24struct BaseView : std::ranges::view_base {25  int* begin() const;26  int* end() const;27};28 29struct TupleView : std::ranges::view_base {30  std::tuple<int>* begin() const;31  std::tuple<int>* end() const;32};33 34struct NestedView : std::ranges::view_base {35  BaseView* begin() const;36  BaseView* end() const;37};38 39struct Pred {40  bool operator()(const auto&...) const;41};42 43struct Sentinel {44  bool operator==(const auto&) const;45};46 47struct Value {48  friend std::istream& operator>>(std::istream&, Value);49};50 51void adl_func(const auto&);52 53} // namespace adl54 55template <class View>56concept CanFindADLFunc = requires(std::ranges::iterator_t<View> it) { adl_func(it); };57 58static_assert(!CanFindADLFunc<std::ranges::elements_view<adl::TupleView, 0>>);59static_assert(!CanFindADLFunc<std::ranges::filter_view<adl::BaseView, adl::Pred>>);60static_assert(!CanFindADLFunc<std::ranges::iota_view<int, adl::Sentinel>>);61 62#ifndef TEST_HAS_NO_LOCALIZATION63static_assert(!CanFindADLFunc<std::ranges::istream_view<adl::Value>>);64#endif65 66static_assert(!CanFindADLFunc<std::ranges::join_view<adl::NestedView>>);67 68static_assert(!CanFindADLFunc<std::ranges::lazy_split_view<adl::BaseView, adl::BaseView>>);69using InnerRange =70    typename std::ranges::iterator_t<std::ranges::lazy_split_view<adl::BaseView, adl::BaseView>>::value_type;71static_assert(!CanFindADLFunc<InnerRange >);72 73static_assert(!CanFindADLFunc<std::ranges::split_view<adl::BaseView, adl::BaseView>>);74static_assert(!CanFindADLFunc<std::ranges::transform_view<adl::BaseView, adl::Pred>>);75 76#if TEST_STD_VER >= 2377static_assert(!CanFindADLFunc<std::ranges::zip_view<adl::BaseView>>);78#endif79