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-exception
6//
7//===----------------------------------------------------------------------===//
8
9// UNSUPPORTED: c++03, c++11, c++14, c++17
10
11// ranges::prev
12// Make sure we're SFINAE-friendly when the template argument constraints are not met.
13
14#include <iterator>
15
16#include <cstddef>
17#include <utility>
18#include "test_iterators.h"
19
20template <class ...Args>
21concept has_ranges_prev = requires (Args&& ...args) {
22 { std::ranges::prev(std::forward<Args>(args)...) };
23};
24
25using It = forward_iterator<int*>;
26static_assert(!has_ranges_prev<It>);
27static_assert(!has_ranges_prev<It, std::ptrdiff_t>);
28static_assert(!has_ranges_prev<It, std::ptrdiff_t, It>);
29
30// Test the test
31using It2 = bidirectional_iterator<int*>;
32static_assert(has_ranges_prev<It2>);
33static_assert(has_ranges_prev<It2, std::ptrdiff_t>);
34static_assert(has_ranges_prev<It2, std::ptrdiff_t, It2>);
35

source code of libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.prev/constraints.compile.pass.cpp