std::ranges...p_while_view(3)
π
std::ranges...p_while_view(3) π
okay so this is the std::ranges...p_while_view(3) page from the C++ Standard Libary manual (spelling as printed, bestie β we respect the typo π«Ά), and we're about to make this constructor make sense. no cap. β¨
πΈ NAME πΈ
std::ranges::drop_while_view::drop_while_viewβstd::ranges::drop_while_view::drop_while_view
that's the constructor, and yes it has main character energy and repeats its own name. iconic. π
β¨ Synopsis β¨
here's the synopsis exactly as printed (formatting is giving very "PDF from 2004" π):
drop_while_view() requires std::default_initializable<V> &&
std::default_initializable<Pred> =
(1) (since C++20)
default;
constexpr explicit drop_while_view( V base, Pred pred );
(2) (since C++20)
Constructs a drop_while_view. π
- Default constructor. Value-initializes the underlying view and the predicate.
- Move constructs the underlying view from
baseand the predicate frompred.
π Parameters π
- base β underlying view
- pred β predicate
π¦ Example π¦
// Run this code
#include <array>
#include <iostream>
#include <ranges>
int main()
{
constexpr std::array data{0, -1, -2, 3, 1, 4, 1, 5};
auto view = std::ranges::drop_while_view
{
data, [](int x) { return x <= 0; }
};
for (int x : view)
std::cout << x << ' ';
std::cout << '\n';
}
π Output: π
3 1 4 1 5
π©Ή Defect reports π©Ή
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
- DR
LWG 3714(P2711R1) β Applied to:C++20. Behavior as published: the multi-parameter constructor was not explicit. Correct behavior: made explicit. - DR
P2325R3β Applied to:C++20. Behavior as published: ifPredis notdefault_initializable, the default constructor constructs adrop_while_viewwhich does not contain anPred. Correct behavior: thedrop_while_viewis also notdefault_initializable.
source/version/date, bestie: http://cppreference.com Β· 2024.06.10 Β· std::ranges...p_while_view(3) β mwah, go be default_initializable π
π¦ 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