-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Should I include single-header after my to_json and from_json custom functions declaration? Why not? #1663
Comments
to_json
and from_json
custom functions declaration?
It's using ADL. The internals are from @theodelrieu - maybe they can share more insights. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Any comments from @theodelrieu ? |
Hello, this is because of two-phase lookup, you can find a short but accurate overview here. Basically, |
@theodelrieu Is this behaviour required by C++ standard (which one?) or could there be some other approach used by compiler? As I see from RSDN and SO discussions many compilers fail to implement two-phase lookup properly, so I assume this library would not work in such case, |
Two-phase lookup was always the expectation, even pre-C++11. Some compilers (eg, MSVC) didn't do it quite right but at this point, I would expect all the C++14 and later compilers to definitely have it down. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
So I was going through the code and can not get how the library find user-defined functions for conversion (
to_json
andfrom_json
)?Let me explain with code.
simple example could look like this:
Before include of
<json.hpp>
there is no declaration ofmynamespace::to/from_json
so I expect any check in<json.hpp>
likehas_custom_to_json
to fail. If not then how it works?My guess is that all the magic is in
is_detected_exact
but I could not figure out how is it possible and what template trick is used?P.S.: Sorry for multiple edits.
The text was updated successfully, but these errors were encountered: