命名空间
变体
操作

std::ranges::forward_range

来自 cppreference.com
< cpp‎ | ranges
 
 
范围库
范围适配器
 
定义在头文件 <ranges>
template< class T >

concept forward_range =

    ranges::input_range<T> && std::forward_iterator<ranges::iterator_t<T>>;
(自 C++20 起)

forward_range 概念是对 range 的细化,其中 ranges::begin 返回 forward_iterator 的模型。

[编辑] 示例

#include <forward_list>
#include <queue>
#include <ranges>
#include <span>
#include <stack>
#include <tuple>
 
const char* str{"not a forward range"};
const char str2[] = "a forward range";
static_assert(
    std::ranges::forward_range<decltype("a forward range")> &&
    !std::ranges::forward_range<decltype(str)> &&
    std::ranges::forward_range<decltype(str2)> &&
    !std::ranges::forward_range<std::stack<char>> &&
    std::ranges::forward_range<std::forward_list<char>> &&
    !std::ranges::forward_range<std::tuple<std::forward_list<char>>> &&
    std::ranges::forward_range<std::span<char>> &&
    !std::ranges::forward_range<std::queue<char>> &&
"");
 
int main() {}