std::ranges::bidirectional_range

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

concept bidirectional_range =

    ranges::forward_range<T> && std::bidirectional_iterator<ranges::iterator_t<T>>;
(C++20 起)

bidirectional_range 概念是 range 的细化,ranges::begin 对它返回 bidirectional_iterator 的实现。

示例

#include <forward_list>
#include <list>
#include <ranges>
#include <set>
#include <unordered_set>
 
int main()
{
    static_assert(
            std::ranges::bidirectional_range<std::set<int>> and
        not std::ranges::bidirectional_range<std::unordered_set<int>> and
            std::ranges::bidirectional_range<std::list<int>> and
        not std::ranges::bidirectional_range<std::forward_list<int>>
    );
}

参阅

指定范围的迭代器类型满足 forward_iterator
(概念)
指定范围的迭代器类型满足 random_access_iterator
(概念)