std::meta::access_context::current
From cppreference.com
static consteval std::meta::access_context current() noexcept;
|
||
Returns a new access_context whose associated scope is the smallest namespace, class, or function scope that encloses the call site, and whose designating class is the null reflection.
Return value
An access_context whose associated scope is the enclosing scope, as described above.
Notes
If current() is used in a default member initializer or default argument, the call site is considered to be the point that uses the initializer or default argument (not where the current() call lexically appears).
consteval auto current_scope(std::meta::info r = std::meta::access_context::current().scope())
{
return r;
}
static_assert(std::meta::is_namespace(current_scope()));
struct S { static_assert(std::meta::is_type(current_scope())); };
void f() { static_assert(std::meta::is_function(current_scope())); }
If current() is used in a function declaration (before the function body, if any), the scope of the function is skipped when determining the enclosing scope.
auto f()
-> std::bool_constant<std::meta::is_namespace(std::meta::access_context::current().scope())>;
static_assert(^^decltype(f()) == dealias(^^std::true_type));
Example
| This section is incomplete Reason: no example |
See also
| returns the associated scope and designating class, respectively (public member function) |