//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14, c++17 // constexpr iterator& operator--() requires decrementable; // constexpr iterator operator--(int) requires decrementable; #include #include #include #include "test_macros.h" #include "../types.h" template concept Decrementable = requires(T i) { --i; } || requires(T i) { i--; }; constexpr bool test() { { std::ranges::iota_view io(0); auto iter1 = std::next(io.begin()); auto iter2 = std::next(io.begin()); assert(iter1 == iter2); assert(--iter1 != iter2--); assert(iter1 == iter2); static_assert(!std::is_reference_v); static_assert( std::is_reference_v); static_assert(std::same_as, decltype(iter2--)>); } { std::ranges::iota_view io(SomeInt(0)); auto iter1 = std::next(io.begin()); auto iter2 = std::next(io.begin()); assert(iter1 == iter2); assert(--iter1 != iter2--); assert(iter1 == iter2); static_assert(!std::is_reference_v); static_assert( std::is_reference_v); static_assert(std::same_as, decltype(iter2--)>); } static_assert(!Decrementable>); return true; } int main(int, char**) { test(); static_assert(test()); return 0; }