Skip to content

Forward declare tuple_size/tuple_element and raw_json, move custom into forward.hpp - #2613

Open
stephenberry wants to merge 1 commit into
mainfrom
forward-decl-additional-types
Open

Forward declare tuple_size/tuple_element and raw_json, move custom into forward.hpp#2613
stephenberry wants to merge 1 commit into
mainfrom
forward-decl-additional-types

Conversation

@stephenberry

Copy link
Copy Markdown
Owner

Follow-up to the glaze/forward.hpp work, addressing the additional types raised in review feedback on #2527.

What

  • glz::tuple_size / glz::tuple_element — forward declare the primary templates (left incomplete) so user headers can register a tuple-like type via specialization without pulling in glaze/tuplet/tuple.hpp. The concrete tuple_size_v / tuple_element_t helpers and the std:: specializations remain owned by tuple.hpp.
  • glz::raw_json — forward declare basic_raw_json plus the raw_json / raw_json_view aliases, supporting use as a default template argument in a generic lambda, e.g.:
    static constexpr auto value = our_glz_wrappers::custom<
      [](T& x, double v) { x = T(v); },
      []<typename raw_json = glz::raw_json>(T x) { return raw_json(our_custom_type_to_string(x)); }
    >;
    The declaration omits the default template argument (std::string), leaving glaze/core/common.hpp as the sole owner of the default and full definition.
  • glz::customcustom_impl() and the custom customization point move from glaze/core/wrappers.hpp into forward.hpp, next to custom_t (which already lived there). Both are trivial and depend only on custom_t.
  • glz::error_code — intentionally left out; it doesn't appear to be used without its definition.

forward.hpp now also includes <cstddef>, <string>, and <string_view> alongside <cstdint>.

Verification

  • forward.hpp standalone compiles and exposes the new names (raw_json as a default template arg, a user tuple_size/tuple_element specialization, glz::custom).
  • forward.hpp + full glaze.hpp compiles in both include orders with no redefinition or default-argument clashes.

…nto forward.hpp

Extend glaze/forward.hpp with the remaining lightweight customization points
flagged in review:

- Forward declare glz::tuple_size / glz::tuple_element so user headers can
  register a tuple-like type without pulling in glaze/tuplet/tuple.hpp. The
  tuple_size_v / tuple_element_t helpers remain owned by tuple.hpp.
- Forward declare glz::basic_raw_json (without its default argument, which
  stays owned by common.hpp) plus the raw_json / raw_json_view aliases, so
  glz::raw_json can be named (e.g. as a default template argument) without the
  full definition.
- Move custom_impl() and the glz::custom customization point from
  core/wrappers.hpp to forward.hpp next to custom_t; both are trivial and
  depend only on custom_t.

Adds <cstddef>, <string>, and <string_view> to forward.hpp's standard-library
includes.
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