Repository navigation
Description
Part of #138
Popularity: 1/7 corpus consumers (sqlgen)
Related issues
Complements #145 (type-name reflection) in reflect-cpp's compile-time reflection helper surface.
Problem
reflect-cpp reflects aggregate struct field names only at the whole-struct level (rfl::named_tuple_t<T>, rfl::fields<T>(), rfl::to_view). It provides no public compile-time helper to extract the name of a single field from a pointer-to-member non-type template parameter (&Struct::member).
Downstream libraries building type-safe query DSLs, patch/diff builders, or field-selector APIs using pointer-to-member syntax (col<&Person::age>) are forced to re-implement compiler-specific <source_location> / __FUNCSIG__ / __PRETTY_FUNCTION__ parsing across Clang, GCC, and MSVC.
Observed Downstream Workaround
munich-data-engineering/sqlgen (265b0a17)
- Added in commit
6097e88("Added support for the member pointer syntax (API/Defaults & Wrappers: all-or-nothing DefaultIfMissing and intrusive metadata wrappers force shadow structs, .value().value_or() churn, and drift static_asserts #147)"),include/sqlgen/internal/get_member_ptr_name.hpp#L15-L70duplicates compiler-specific function-signature slicing and then packs the result back intorfl::internal::StringLiteralso it can interoperate withrfl::Field,rfl::Literal, andrfl::field_type_t:(Note linestemplate <class T, auto ptr> consteval auto get_member_ptr_name_str_view() { #if __cpp_lib_source_location >= 201907L const auto func_name = std::string_view{std::source_location::current().function_name()}; #elif defined(_MSC_VER) const auto func_name = std::string_view{__FUNCSIG__}; #else const auto func_name = std::string_view{__PRETTY_FUNCTION__}; #endif #if defined(__clang__) const auto split = func_name.substr(0, func_name.size() - 1); return split.substr(split.find_last_of(":.") + 1); #elif defined(__GNUC__) const auto split = func_name.substr(0, func_name.size() - 1); return split.substr(split.find_last_of(":.") + 1); #elif defined(_MSC_VER) auto split = func_name.substr(0, func_name.size() - 7); auto pos = split.find_last_of(":"); if (pos != std::string_view::npos) { return split.substr(pos + 1); } return split; #else static_assert( false, "You are using an unsupported compiler. Please use GCC, Clang " "or MSVC or explicitly tag your structs using 'Tag' or 'Name'."); #endif }
L41-L44even retainreflect-cpp's verbatim unsupported-compiler error message referencing'Tag' or 'Name', confirming it was adapted directly fromreflect-cpp's internal reflection machinery.) - Consumed in
include/sqlgen/col.hpp#L259-L278to powersqlgen::col<&Person::age>.
Root Cause in reflect-cpp & Suggested Direction
reflect-cpp already owns and maintains the cross-compiler signature-parsing machinery for Clang, GCC, AppleClang, and MSVC (and will eventually back it with C++26 reflection). Exposing a public consteval pointer-to-member name helper — e.g., rfl::field_name<&T::m>() / rfl::field_name_v<&T::m> returning constexpr std::string_view (and/or a public rfl::StringLiteral variant) — would eliminate duplicated brittle compiler #ifdefs in downstream reflection consumers.
Activity
clockblocker commentedon Nov 29, 2026
Triage decision: closing as
wontfix(not planned) for the upstream adoption track.Rationale:
sqlgen-only internal reflection primitive (member-pointer&T::fieldname extraction).sqlgenis authored byreflect-cpp's own maintainer; if this primitive is wanted inrfl, he can promote it directly without an external PR. Zero external adoption leverage.