Skip to content

Avoid lambdas in class template static member initializers (MSVC) - #3004

Merged
stephenberry merged 1 commit into
mainfrom
msvc-static-member-lambdas
Oct 15, 2026
Merged

stephenberry merged 1 commit into
mainfrom
msvc-static-member-lambdas

Conversation

@stephenberry

Copy link
Copy Markdown
Owner

MSVC intermittently fails to compile beve_test: it resolves the immediately invoked lambda in BEVE's object writer (beve/write.hpp) to the lambda in meta<std::tuple<...>>::name's initializer, an unrelated closure type (C3889, then C3536). The BEVE code has not changed; the failure comes and goes across unrelated PRs.

This removes immediately invoked lambdas from the static data member initializers of class templates, the pattern MSVC confused:

  • meta<std::tuple>, meta<std::variant> and meta<glz::tuple> build their names with a new comma_separated_names_v<T...> variable template.
  • trait<T>::members uses a detail::trait_member_names<T>() function.

The generated names and API hashes (glz::hash<T>()) are unchanged.

@stephenberry
stephenberry merged commit 828f16c into main Oct 15, 2026
66 checks passed
@stephenberry
stephenberry deleted the msvc-static-member-lambdas branch October 15, 2026 15:36
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.

1 participant