Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro for adding custom types to Value::as<T>() #45

Open
heyx3 opened this issue Feb 4, 2020 · 0 comments
Open

Macro for adding custom types to Value::as<T>() #45

heyx3 opened this issue Feb 4, 2020 · 0 comments

Comments

@heyx3
Copy link

heyx3 commented Feb 4, 2020

It would be nice to be able to support our own custom types to the TOML parser through templates, so that we could simply write value.as<My_t>() for any My_t that we want . Based on my reading of the source, it's already possible without touching the source by adding new template specialization for a few types. I made a macro in my project to do this; I haven't tested it yet, but would you be interested in a pull request to add this type of functionality?

I'd also like to provide an automatic way to deserialize a custom type, but I'm not sure how to do that yet; it might require source modification.

Edit: forgot to mention, I also used this in my project to provide parsers for all the different integer and float types, because the project currently only accepts int64_t and double. Would you be interested in that as well?

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

No branches or pull requests

1 participant