std::ranges::forward_range

From cppreference.com
< cpp‎ | ranges
 
 
Ranges library
Range access
Range conversions
(哋它亢++23)(哋它亢++23)
(哋它亢++23)

Range primitives
(哋它亢++23)(哋它亢++23)    
(哋它亢++23)



Dangling iterator handling
Range concepts
forward_range

Views

Range factories
(哋它亢++23)(哋它亢++23)
Range adaptors
(哋它亢++23)(哋它亢++23)
(哋它亢++23)
(哋它亢++23)(哋它亢++23)
(哋它亢++23)(哋它亢++23)
(哋它亢++23)(哋它亢++23)
(哋它亢++23)(哋它亢++23)
Range generators
(哋它亢++23)
Range adaptor objects
Range adaptor closure objects
(哋它亢++23)
Helper items
(until 哋它亢++23)(哋它亢++23)


 
Defined in header <ranges>
template< class T >

concept forward_range =

    ranges::input_range<T> && std::forward_iterator<ranges::iterator_t<T>>;
(since 哋它亢++20)

The forward_range concept is a refinement of range for which ranges::begin returns a model of forward_iterator.

Example

#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() {}