File tree Expand file tree Collapse file tree 2 files changed +32
-66
lines changed
Expand file tree Collapse file tree 2 files changed +32
-66
lines changed Original file line number Diff line number Diff line change @@ -71,4 +71,36 @@ public:
7171 }
7272};
7373
74+ consteval std::meta::info current_scope(
75+ std::meta::info ctx = std::meta::access_context::current().scope()) {
76+ return ctx;
77+ }
78+
79+ consteval std::meta::info current_function(std::meta::info scope = current_scope()) {
80+ if (is_function(scope)) {
81+ return scope;
82+ }
83+ throw "not in a function";
84+ }
85+
86+ consteval std::meta::info current_class(std::meta::info scope = current_scope()) {
87+ while (not is_namespace(scope)) {
88+ if (is_type(scope)) {
89+ return scope;
90+ }
91+ scope = parent_of(scope);
92+ }
93+ throw "not in a class";
94+ }
95+
96+ consteval std::meta::info current_namespace(std::meta::info scope = current_scope()) {
97+ while (scope != ^^::) {
98+ if (is_namespace(scope)) {
99+ return scope;
100+ }
101+ scope = parent_of(scope);
102+ }
103+ return ^^::;
104+ }
105+
74106} // namespace rsl
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments