std::derived_from(3cxx)

πŸ“¦
version 16-20260322 Β· 3 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– std::derived_from β€” from the 3cxx manual πŸ’–

okay bestie, pull up a chair, because today we're learning about a concept, and not in the abstract "what is the meaning of life" way β€” in the C++20 way. this is a page from the libstdc++ manual and it's about to be your new fave. no cap. πŸ¦‹


✨ NAME ✨

std::derived_from β€” [concept.derived], the concept derived_from

like... the name is the whole vibe. it checks if one thing derives from another thing. iconic behaviour honestly. πŸ’…


🌸 SYNOPSIS 🌸

first thing's first, you gotta let it into your life:

#include <concepts>

that's the gate. that's the whole entrance exam. header included, concept unlocked, periodt. πŸ”₯

πŸŽ€ Concept definition πŸŽ€

here's the actual shape of it, and yes you're gonna look at every single character because this is the exact definition:

template<typename _Derived, typename _Base>
concept std::derived_from =  __is_base_of(_Base, _Derived)
      && is_convertible_v<const volatile _Derived*, const volatile _Base*>

so the way this works, bestie: it's a concept with two template parameters, _Derived and _Base, and it's true when both of these hold β€” __is_base_of(_Base, _Derived) is true, and is_convertible_v<const volatile _Derived*, const volatile _Base*> is true. two conditions, one &&, no shortcuts. it's giving "both boxes checked or we don't move." πŸ‘‘


πŸ’œ DESCRIPTION πŸ’œ

[concept.derived], concept derived_from. that's the detailed description, and honestly? it's short and it knows it. some entries ramble, this one serves. ✨


🫢 Author 🫢

Generated automatically by Doxygen for libstdc++ from the source code.

so like, a robot wrote this part. don't @ me, I just report the facts. πŸ™ˆ

and that's the whole page, bestie! shoutout to libstdc++ for the 3cxx manual this came from β€” mwah, thanks for the source, love u, bye! πŸ’–πŸŽ€πŸ¦‹πŸŒΈπŸ’