A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/language/../ranges/enumerate_view/../all_view.html below:

std::ranges::views::all, std::ranges::views::all_t - cppreference.com

inline constexpr /* unspecified */ all = /* unspecified */;

(1) (since C++20) (2) (since C++20) [edit] Example
#include <iostream>
#include <ranges>
#include <type_traits>
#include <vector>
 
int main()
{
    std::vector<int> v{0, 1, 2, 3, 4, 5};
    for (int n : std::views::all(v) | std::views::take(2))
        std::cout << n << ' ';
    std::cout << '\n';
 
    static_assert(std::is_same<
        decltype(std::views::single(42)),
        std::ranges::single_view<int>
        >{});
 
    static_assert(std::is_same<
        decltype(std::views::all(v)),
        std::ranges::ref_view<std::vector<int, std::allocator<int>>>
        >{});
 
    int a[]{1, 2, 3, 4};
    static_assert(std::is_same<
        decltype(std::views::all(a)),
        std::ranges::ref_view<int[4]>
        >{});
 
    static_assert(std::is_same<
        decltype(std::ranges::subrange{std::begin(a) + 1, std::end(a) - 1}),
        std::ranges::subrange<int*, int*, std::ranges::subrange_kind(1)>
        >{});
}

Output:

[edit] Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior LWG 3724 C++20 views::all might result in hard error for some move-only views it gets well-constrained P2415R2 C++20 views::all returned a subrange for a non-view rvalue range returns an owning_view for it [edit] See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4