Skip to content

Conversation

@bruce-webb
Copy link

*Issue number of the reported bug or feature request: p3394 usage

Describe your changes
When using a custom annotations and getting access to it with the function annotation_of_type the T is required to be equality_comparable.

If not the compile error message leads down to missing operator != for the type

Testing performed
When testing with new annotations types clangd reports that T doesn't meet the requires clauses. The compile message is also cleaner as well.

namespace lua {
struct rename {
  const char *name;
  
  auto operator<=>(const rename &) const = default;
};

struct Person
{
  [[=lua::rename("firstName")]] std::string first_name;
};

template<typename T>
consteval auto GetName() -> std::string_view {
    return
        std::meta::annotation_of_type<lua::rename>(^^T)
            .transform([](lua::rename rename) {
              return std::string_view(rename.name);
            })
            .value_or(std::meta::display_string_of(^^T));
}

@katzdm katzdm force-pushed the p2996 branch 2 times, most recently from 3cc9fcd to 4ffd254 Compare April 11, 2025 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants