Skip to content

Conversation

@grisumbras
Copy link
Member

Very rough draft of the idea.

For a context type Ctx the user is supposed to implement these functions:

void tag_invoke(context_key_push_tag, string_view,  Ctx const&);
void tag_invoke(context_key_pop_tag, Ctx const&);
void tag_invoke(context_index_push_tag, std::size_t, Ctx const&);
void tag_invoke(context_index_pop_tag, Ctx const&);

The library would invoke them when traversing through the converted/parsed/serialized value.

Things to think about:

  • The user may actually want to set error_code in those callbacks.
  • The user may want to clear error_code in those functions. But then where would we get the results the calling function was supposed to create?

@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://1075.json.prtest2.cppalliance.org/libs/json/doc/html/index.html

@cppalliance-bot
Copy link

@RoyBellingan
Copy link

Is very interesting and clean.
I would suggest in this section

https://github.com/grisumbras/json/blob/e4e192a84f7482aaad923575e34e6f37669252d0/include/boost/json/detail/value_to.hpp#L376

To move the
json::context_key_push(ctx, D::name);

Before the check, so we can capture the "last processed" json pointer

@sdebionne
Copy link

This MR fulfills my needs -thank you for that- and I would be glad if it get merged at some point.

But the CI fails for compilers other than GCC because it handles C++ variadic function in a different way. Other compilers treat them as C variadic function and complain that it cannot pass object of non-trivial type through variadic function.

Is there any way around that? Was this just a convenient way of forward declaring the tag_invoke customization points for the new tags?

Comment on lines +566 to +588
inline
void
tag_invoke(context_key_push_tag, string_view, ...)
{
}

inline
void
tag_invoke(context_key_pop_tag, ...)
{
}

inline
void
tag_invoke(context_index_push_tag, std::size_t, ...)
{
}

inline
void
tag_invoke(context_index_pop_tag, ...)
{
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was referring to these lines in the above comment.

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.

4 participants