Is there a good way to detect which types support writing / reading to json? #1620
Replies: 2 comments 10 replies
-
The issue with aggregate initializable structs is that we're using the compiler to detect the number of elements. You can add a |
Beta Was this translation helpful? Give feedback.
-
Note that the |
Beta Was this translation helpful? Give feedback.
-
I have a use-case where I need to compile-time check if a type will cause compilation errors when calling
write_json()
. I saw thewrite_json_supported
concept, and it seemed perfect:This correctly filters out structs that aren't aggregate initializable:
However, this doesn't filter out aggregate initializable structs whose members cannot be serialized:
I'm working around this by manually having a type trait to specify which types to serialize, but I'm wondering: is there a way in Glaze to automatically know what types support
write_json()
?Beta Was this translation helpful? Give feedback.
All reactions