| 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 |
|
| 20 |
template <class ...Args> |
| 21 |
concept has_ranges_prev = requires (Args&& ...args) { |
| 22 |
{ std::ranges::prev(std::forward<Args>(args)...) }; |
| 23 |
}; |
| 24 |
|
| 25 |
using It = forward_iterator<int*>; |
| 26 |
static_assert(!has_ranges_prev<It>); |
| 27 |
static_assert(!has_ranges_prev<It, std::ptrdiff_t>); |
| 28 |
static_assert(!has_ranges_prev<It, std::ptrdiff_t, It>); |
| 29 |
|
| 30 |
// Test the test |
| 31 |
using It2 = bidirectional_iterator<int*>; |
| 32 |
static_assert(has_ranges_prev<It2>); |
| 33 |
static_assert(has_ranges_prev<It2, std::ptrdiff_t>); |
| 34 |
static_assert(has_ranges_prev<It2, std::ptrdiff_t, It2>); |