Skip to content

[feature request] Domain specific conversions #647

@klemens-morgenstern

Description

@klemens-morgenstern

I mentioned that to Vinnie already, but I'd profit from a context object for json, and after some thinking I'd just go for an additional parameter getting passed by const ref and propagated to all the tag_invokes. I don't know if the current overload resolution would work with this though.

json::value_from(T, some_tag{}); void tag_invoke(json::value_from_tag, json::value &target, const U &src, const some_tag &); json::value_to<T>(json::value, some_tag{}); void tag_invoke(json::value_to_tag<U>, json::value &target, const some_tag &);

but that would allow me to attach a context, e.g. to turn all the std::chrono types into ISO8601 string including proper adl for that:

namespace my_date_library { struct my_date_tag; void tag_invoke(json::value_from_tag, json::value &target, const U &src, const my_date_tag &); void tag_invoke(json::value_to_tag<U>, json::value &target, const my_date_tag &); }

and then I can combine those into my own tag:

struct klemens_tag: my_date_library::my_date_tag {};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions