std::experi...DerivedFrom(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– NAME πŸ’–

okay bestie, welcome to the std::experi...DerivedFrom(3) page from the C++ Standard Libary manual β€” yes, β€œLibary” with one β€œr”, that’s the header’s vibe, iykyk. This page is about std::experimental::ranges::DerivedFrom, and the NAME line is literally std::experimental::ranges::DerivedFrom β€” std::experimental::ranges::DerivedFrom. No cap, that’s the whole thing. πŸ’…

✨ Synopsis ✨

Defined in header <experimental/ranges/concepts>:

template< class T, class U >

concept bool DerivedFrom =
    std::is_base_of<U, T>::value &&
(ranges TS)

    std::is_convertible<std::remove_cv_t<T>*,
std::remove_cv_t<U>*>::value;

The concept DerivedFrom<T, U> is satisfied if and only if U is a class type that is either T or a public and unambiguous base of T. That’s the whole requirement, bestie β€” no extra credit. 🫢

Okay but here’s the tea: despite the use of std::is_base_of and std::is_convertible in its description above, DerivedFrom is not required to use it in its implementation. So there need not be any subsumption relationship between DerivedFrom<T, U> and std::is_base_of<U,T>::value or std::is_convertible<std::remove_cv_t<T>*, std::remove_cv_t<U>*>::value. Like, the description above uses those helpers, but the implementation doesn’t have to β€” the vibe is adjacent, not mandatory. 😭

🌈 See also 🌈

  • is_base_of β€” checks if a type is derived from the other type. (C++11) (class template)
  • is_convertible β€” checks if a type can be converted to the other type. (C++11) (class template)
  • is_nothrow_convertible β€” checks if a type can be converted to the other type. (C++20) (class template)

sign-off bestie: source is http://cppreference.com, version/date is 2024.06.10, and the page tag is std::experi...DerivedFrom(3) β€” go off, read the docs, and hydrate while you’re at it πŸ’–βœ¨πŸŒΈ

πŸ“¦ where this page comes from