Get the latest tech news
Reflection for C++26
make_integer_sequence hash_append tuple_cat ^) [:… :]) std::meta::info name_of, display_name_of, source_location_of type_of, parent_of, dealias object_of, value_of template_of, template_arguments_of members_of, static_data_members_of, nonstatic_data_members_of, bases_of, enumerators_of, subobjects_of substitute reflect_invoke reflect_value, reflect_object, reflect_function extract<T> test_trait data_member_spec, define_class typedef specifier using enum declaration <type_traits> synopsis <meta> synopsis Since [P2996R3]: u8name_of, u8qualified_name_of, u8display_name_of. reflect_value: separated reflect_result into three functions: reflect_value, reflect_object, reflect_function is_noexcept to apply to a wider class of entities test_type and test_types to test_trait has_module_linkage metafunction object_of metafunction Since [P2996R2]: accessible_members_of variants to restore a TS-era agreement value_of to extract, and expanded it to operate on functions can_substitute, is_value, is_object, and (new) value_of meta::info yield a null reflection reflect_invoke to support template arguments type_ to avoid name clashes.
the “<unnamed>” case could instead output a valid cast expression like “E(5)” a more sophisticated lookup algorithm could be selected at compile time depending on the length of enumerators_of(^ E) a compact two-way persistent data structure could be generated to support both enum_to_string and string_to_enum with a minimal footprint etc. One option that was recently brought up was@ primary-expression which would allow writing@e for the simple identifier splices but for the more complex operations still require parenthesizing for readability.$< expr> is somewhat natural to those of us that have used systems where$ is used to expand placeholders in document templates: These cases are not difficult to identify: Given an entity E and two program points P1 and P2 from which a reflection of E may be optained, it is unsafe to branch runtime code generation on any property of E(e.g., namespace members, parameter names, completeness of a class) that can be modified between P1 and P2.
Or read this on Hacker News