1*12978b3eSJakub Mazurkiewicz //===----------------------------------------------------------------------===// 2*12978b3eSJakub Mazurkiewicz // 3*12978b3eSJakub Mazurkiewicz // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*12978b3eSJakub Mazurkiewicz // See https://llvm.org/LICENSE.txt for license information. 5*12978b3eSJakub Mazurkiewicz // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*12978b3eSJakub Mazurkiewicz // 7*12978b3eSJakub Mazurkiewicz //===----------------------------------------------------------------------===// 8*12978b3eSJakub Mazurkiewicz 9*12978b3eSJakub Mazurkiewicz // UNSUPPORTED: c++03, c++11, c++14, c++17 10*12978b3eSJakub Mazurkiewicz 11*12978b3eSJakub Mazurkiewicz // <compare>, <iterator>, <ranges> 12*12978b3eSJakub Mazurkiewicz 13*12978b3eSJakub Mazurkiewicz // ADL should be performed. Ordinary unqualified lookup should not be performed. 14*12978b3eSJakub Mazurkiewicz 15*12978b3eSJakub Mazurkiewicz namespace ns { 16*12978b3eSJakub Mazurkiewicz struct StructWithGlobalFunctions {}; 17*12978b3eSJakub Mazurkiewicz } // namespace ns 18*12978b3eSJakub Mazurkiewicz 19*12978b3eSJakub Mazurkiewicz struct ConvertibleToCmpType; 20*12978b3eSJakub Mazurkiewicz ConvertibleToCmpType strong_order(const ns::StructWithGlobalFunctions&, const ns::StructWithGlobalFunctions&); 21*12978b3eSJakub Mazurkiewicz ConvertibleToCmpType weak_order(const ns::StructWithGlobalFunctions&, const ns::StructWithGlobalFunctions&); 22*12978b3eSJakub Mazurkiewicz ConvertibleToCmpType partial_order(const ns::StructWithGlobalFunctions&, const ns::StructWithGlobalFunctions&); 23*12978b3eSJakub Mazurkiewicz 24*12978b3eSJakub Mazurkiewicz int&& iter_move(const ns::StructWithGlobalFunctions&); 25*12978b3eSJakub Mazurkiewicz void iter_swap(const ns::StructWithGlobalFunctions&, const ns::StructWithGlobalFunctions&); 26*12978b3eSJakub Mazurkiewicz 27*12978b3eSJakub Mazurkiewicz int* begin(const ns::StructWithGlobalFunctions&); 28*12978b3eSJakub Mazurkiewicz int* end(const ns::StructWithGlobalFunctions&); 29*12978b3eSJakub Mazurkiewicz int* rbegin(const ns::StructWithGlobalFunctions&); 30*12978b3eSJakub Mazurkiewicz int* rend(const ns::StructWithGlobalFunctions&); 31*12978b3eSJakub Mazurkiewicz unsigned int size(const ns::StructWithGlobalFunctions&); 32*12978b3eSJakub Mazurkiewicz 33*12978b3eSJakub Mazurkiewicz #include <compare> 34*12978b3eSJakub Mazurkiewicz #include <ranges> 35*12978b3eSJakub Mazurkiewicz #include <type_traits> 36*12978b3eSJakub Mazurkiewicz 37*12978b3eSJakub Mazurkiewicz struct ConvertibleToCmpType { 38*12978b3eSJakub Mazurkiewicz operator std::strong_ordering() const; 39*12978b3eSJakub Mazurkiewicz operator std::weak_ordering() const; 40*12978b3eSJakub Mazurkiewicz operator std::partial_ordering() const; 41*12978b3eSJakub Mazurkiewicz }; 42*12978b3eSJakub Mazurkiewicz 43*12978b3eSJakub Mazurkiewicz struct StructWithHiddenFriends { 44*12978b3eSJakub Mazurkiewicz friend ConvertibleToCmpType strong_order(const StructWithHiddenFriends&, const StructWithHiddenFriends&); 45*12978b3eSJakub Mazurkiewicz friend ConvertibleToCmpType weak_order(const StructWithHiddenFriends&, const StructWithHiddenFriends&); 46*12978b3eSJakub Mazurkiewicz friend ConvertibleToCmpType partial_order(const StructWithHiddenFriends&, const StructWithHiddenFriends&); 47*12978b3eSJakub Mazurkiewicz 48*12978b3eSJakub Mazurkiewicz friend int&& iter_move(const StructWithHiddenFriends&); 49*12978b3eSJakub Mazurkiewicz friend void iter_swap(const StructWithHiddenFriends&, const StructWithHiddenFriends&); 50*12978b3eSJakub Mazurkiewicz 51*12978b3eSJakub Mazurkiewicz friend int* begin(const StructWithHiddenFriends&); 52*12978b3eSJakub Mazurkiewicz friend int* end(const StructWithHiddenFriends&); 53*12978b3eSJakub Mazurkiewicz friend int* rbegin(const StructWithHiddenFriends&); 54*12978b3eSJakub Mazurkiewicz friend int* rend(const StructWithHiddenFriends&); 55*12978b3eSJakub Mazurkiewicz friend unsigned int size(const StructWithHiddenFriends&); 56*12978b3eSJakub Mazurkiewicz }; 57*12978b3eSJakub Mazurkiewicz 58*12978b3eSJakub Mazurkiewicz // [cmp.alg] ADL should be performed. 59*12978b3eSJakub Mazurkiewicz static_assert(std::is_invocable_v<decltype(std::strong_order), StructWithHiddenFriends&, StructWithHiddenFriends&>); 60*12978b3eSJakub Mazurkiewicz static_assert(std::is_invocable_v<decltype(std::weak_order), StructWithHiddenFriends&, StructWithHiddenFriends&>); 61*12978b3eSJakub Mazurkiewicz static_assert(std::is_invocable_v<decltype(std::partial_order), StructWithHiddenFriends&, StructWithHiddenFriends&>); 62*12978b3eSJakub Mazurkiewicz 63*12978b3eSJakub Mazurkiewicz // [cmp.alg] Ordinary unqualified lookup should not be performed. 64*12978b3eSJakub Mazurkiewicz static_assert( 65*12978b3eSJakub Mazurkiewicz !std::is_invocable_v<decltype(std::strong_order), ns::StructWithGlobalFunctions&, ns::StructWithGlobalFunctions&>); 66*12978b3eSJakub Mazurkiewicz static_assert( 67*12978b3eSJakub Mazurkiewicz !std::is_invocable_v<decltype(std::weak_order), ns::StructWithGlobalFunctions&, ns::StructWithGlobalFunctions&>); 68*12978b3eSJakub Mazurkiewicz static_assert( 69*12978b3eSJakub Mazurkiewicz !std::is_invocable_v<decltype(std::partial_order), ns::StructWithGlobalFunctions&, ns::StructWithGlobalFunctions&>); 70*12978b3eSJakub Mazurkiewicz 71*12978b3eSJakub Mazurkiewicz // [iterator.cust] ADL should be performed. 72*12978b3eSJakub Mazurkiewicz static_assert(std::is_invocable_v<decltype(std::ranges::iter_move), StructWithHiddenFriends&>); 73*12978b3eSJakub Mazurkiewicz static_assert( 74*12978b3eSJakub Mazurkiewicz std::is_invocable_v<decltype(std::ranges::iter_swap), StructWithHiddenFriends&, StructWithHiddenFriends&>); 75*12978b3eSJakub Mazurkiewicz 76*12978b3eSJakub Mazurkiewicz // [iterator.cust] Ordinary unqualified lookup should not be performed. 77*12978b3eSJakub Mazurkiewicz static_assert(!std::is_invocable_v<decltype(std::ranges::iter_move), ns::StructWithGlobalFunctions&>); 78*12978b3eSJakub Mazurkiewicz static_assert(!std::is_invocable_v<decltype(std::ranges::iter_swap), 79*12978b3eSJakub Mazurkiewicz ns::StructWithGlobalFunctions&, 80*12978b3eSJakub Mazurkiewicz ns::StructWithGlobalFunctions&>); 81*12978b3eSJakub Mazurkiewicz 82*12978b3eSJakub Mazurkiewicz // [range.access] ADL should be performed. 83*12978b3eSJakub Mazurkiewicz static_assert(std::is_invocable_v<decltype(std::ranges::begin), StructWithHiddenFriends&>); 84*12978b3eSJakub Mazurkiewicz static_assert(std::is_invocable_v<decltype(std::ranges::cbegin), StructWithHiddenFriends&>); 85*12978b3eSJakub Mazurkiewicz static_assert(std::is_invocable_v<decltype(std::ranges::end), StructWithHiddenFriends&>); 86*12978b3eSJakub Mazurkiewicz static_assert(std::is_invocable_v<decltype(std::ranges::cend), StructWithHiddenFriends&>); 87*12978b3eSJakub Mazurkiewicz static_assert(std::is_invocable_v<decltype(std::ranges::rbegin), StructWithHiddenFriends&>); 88*12978b3eSJakub Mazurkiewicz static_assert(std::is_invocable_v<decltype(std::ranges::crbegin), StructWithHiddenFriends&>); 89*12978b3eSJakub Mazurkiewicz static_assert(std::is_invocable_v<decltype(std::ranges::rend), StructWithHiddenFriends&>); 90*12978b3eSJakub Mazurkiewicz static_assert(std::is_invocable_v<decltype(std::ranges::crend), StructWithHiddenFriends&>); 91*12978b3eSJakub Mazurkiewicz static_assert(std::is_invocable_v<decltype(std::ranges::size), StructWithHiddenFriends&>); 92*12978b3eSJakub Mazurkiewicz 93*12978b3eSJakub Mazurkiewicz // [range.access] Ordinary unqualified lookup should not be performed. 94*12978b3eSJakub Mazurkiewicz static_assert(!std::is_invocable_v<decltype(std::ranges::begin), ns::StructWithGlobalFunctions&>); 95*12978b3eSJakub Mazurkiewicz static_assert(!std::is_invocable_v<decltype(std::ranges::cbegin), ns::StructWithGlobalFunctions&>); 96*12978b3eSJakub Mazurkiewicz static_assert(!std::is_invocable_v<decltype(std::ranges::end), ns::StructWithGlobalFunctions&>); 97*12978b3eSJakub Mazurkiewicz static_assert(!std::is_invocable_v<decltype(std::ranges::cend), ns::StructWithGlobalFunctions&>); 98*12978b3eSJakub Mazurkiewicz static_assert(!std::is_invocable_v<decltype(std::ranges::rbegin), ns::StructWithGlobalFunctions&>); 99*12978b3eSJakub Mazurkiewicz static_assert(!std::is_invocable_v<decltype(std::ranges::crbegin), ns::StructWithGlobalFunctions&>); 100*12978b3eSJakub Mazurkiewicz static_assert(!std::is_invocable_v<decltype(std::ranges::rend), ns::StructWithGlobalFunctions&>); 101*12978b3eSJakub Mazurkiewicz static_assert(!std::is_invocable_v<decltype(std::ranges::crend), ns::StructWithGlobalFunctions&>); 102*12978b3eSJakub Mazurkiewicz static_assert(!std::is_invocable_v<decltype(std::ranges::size), ns::StructWithGlobalFunctions&>); 103