std::ranges...ional_range(3)
std::ranges::bidirectional_range(3) π
okay bestie, welcome to the C++ Standard Libary manual β section 3, the std::ranges::bidirectional_range page. no cap, we're in range-concept territory and it's lowkey iconic. π¦
β¨ NAME β¨
std::ranges::bidirectional_range - std::ranges::bidirectional_range β yes, the NAME line is literally the same thing twice, and honestly? main character energy. π«Ά
π¦ Synopsis π¦
Defined in header <ranges>.
(since C++20) bestie, this one's a C++20 baby. β¨
template< class T >
concept bidirectional_range =
ranges::forward_range<T> &&
std::bidirectional_iterator<ranges::iterator_t<T>>;
The bidirectional_range concept is a refinement of range for which ranges::begin returns a model of bidirectional_iterator. that's the whole vibe: ranges::begin has to give you a bidirectional_iterator model, periodt. π₯
π Example π
here's the demo, bestie β run this code if you want, it's giving valid concept checks. π
// Run this code
#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>>
);
}
π See also π
ranges::forward_range(C++20) β specifies a range whose iterator type satisfiesforward_iterator(concept)ranges::random_access_range(C++20) β specifies a range whose iterator type satisfiesrandom_access_iterator(concept)
okay that's the page, bestie π source: http://cppreference.com, version/date: 2024.06.10, and it's the std::ranges::bidirectional_range(3) page. mwah πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms