std::experi...::projected(3)

๐Ÿ“ฆ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

๐ŸŒธ NAME ๐ŸŒธ

std::experimental::ranges::projected โ€” bestie, this is literally the page for std::experimental::ranges::projected ๐Ÿ’…

okay so first things first: this page lives in the C++ Standard Libary manual โ€” yep, โ€œLibary,โ€ thatโ€™s the spelling on the tin ๐Ÿซถ โ€” and its header title is std::experi...::projected(3). No cap, thatโ€™s the whole vibe check.


โœจ Synopsis โœจ

Defined in header <experimental/ranges/iterator>:

template< Readable I, IndirectRegularUnaryInvocable<I> Proj >
struct projected {
    using value_type =
        std::remove_cv_t<std::remove_reference_t<ranges::indirect_result_of_t<Proj&(I)>>>;
    ranges::indirect_result_of_t<Proj&(I)> operator*() const;
};
(TS)

template< WeaklyIncrementable I, class Proj >
struct difference_type<projected<I, Proj>> {
    using type = ranges::difference_type_t<I>;
};

The class template projected bundles a Readable type I and a function Proj into a brand-new Readable type โ€” and bestie, that new typeโ€™s reference type is literally the result of applying Proj to the reference type of I โœจ.

It exists solely to ease constraint specification, so thatโ€™s its whole main-character job ๐ŸŽ€. Because of that, its operator*() may not actually be defined โ€” like, it might just be there for the constraints, not for actual dereferencing ๐Ÿ‘€. Not me warning you about a possibly-undefined operator*() โ€” itโ€™s giving โ€œlook with your eyes, not your handsโ€ ๐Ÿ’€.

Real talk: operator*() may not actually be defined. Thatโ€™s not a bug in the rewrite, thatโ€™s the original tea โ˜•.

okay bye bestie ๐Ÿ’– this little gem came from http://cppreference.com, with source/version date 2024.06.10, and itโ€™s page std::experi...::projected(3) โ€” mwah ๐Ÿ’‹

๐Ÿ“ฆ where this page comes from