brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 5062a95 Raw
35 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// ranges::prev12// 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 test31using 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