37 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::next12// Make sure we're SFINAE-friendly when the template argument constraints are not met.13 14#include <iterator>15 16#include <cstddef>17#include <memory>18#include <utility>19#include "test_iterators.h"20 21template <class ...Args>22concept has_ranges_next = requires (Args&& ...args) {23 { std::ranges::next(std::forward<Args>(args)...) };24};25 26using It = std::unique_ptr<int>;27static_assert(!has_ranges_next<It>);28static_assert(!has_ranges_next<It, std::ptrdiff_t>);29static_assert(!has_ranges_next<It, It>);30static_assert(!has_ranges_next<It, std::ptrdiff_t, It>);31 32// Test the test33using It2 = forward_iterator<int*>;34static_assert(has_ranges_next<It2>);35static_assert(has_ranges_next<It2, std::ptrdiff_t>);36static_assert(has_ranges_next<It2, std::ptrdiff_t, It2>);37