std::meta::parent_of - cppreference.com
From cppreference.com
consteval std::meta::info parent_of( std::meta::info r ); |
(since C++26) | |
Determines the smallest class, enumeration, function, or namespace scope that contains the declaration of what r represents. Returns a reflection of that class/enum/function/namespace.
If r represents a non-static data member or unnamed bit-field of an anonymous union, the result represents that union.
If r represents a direct base class relationship (i.e. an element of std::meta::bases_of(rc, ctx)), the result represents the derived class in the relationship.
Parameters
Return value
A reflection of the entity whose scope contains the declaration of what r represents.
Exceptions
Throws std::meta::exception unless std::meta::has_parent(r) is true.
Example
#include <meta> struct I {}; struct F : I { union { int o; }; enum N { A }; }; constexpr auto ctx = std::meta::access_context::current(); static_assert(std::meta::parent_of(^^F) == ^^::); static_assert(std::meta::parent_of(std::meta::bases_of(^^F, ctx)[0]) == ^^F); static_assert(std::meta::is_union_type(std::meta::parent_of(^^F::o))); static_assert(std::meta::parent_of(^^F::N) == ^^F); static_assert(std::meta::parent_of(^^F::A) == ^^F::N); int main() {}
See also
| checks if the reflected entity is contained in a scope (function) [edit] |