Comments (7)
Agreed, I think glaze_reflect = true
should override.
from glaze.
As a note, many cases may want the enum serialized as integers. Supporting that is worthwhile.
from glaze.
I agree, the default behavior should still be integers.
I think reflection should happen if a glz::meta
simply exists for the type:
enum class Color { Red, Green, Blue };
template <>
struct glz::meta<Color> {}; // This definition should trigger enum reflection
from glaze.
What are your thoughts on making it such that reflect = true
must be in the struct to trigger reflection? It seems more explicit to me.
Then, as usual, the standard value = enumerate(...)
would override.
from glaze.
Yeah, I think this is probably better for consistency, and then you can flip the reflect flag programmatically if you want:
template <>
struct glz::meta<Color> {
static constexpr auto reflect = true;
};
from glaze.
Ouu, yes, flipping would be nice.
So, what would happen here?
template <>
struct glz::meta<Color> {
static constexpr bool reflect = true;
static constexpr auto value = enumerate(...);
};
I would think precedence would be as follows, meaning the above would autoreflect, regardless of value
.
reflect == true
-> auto reflect regardless ofvalue
(could instead produce an error ifvalue
is also present?)- no reflect and has enumerate
value
member -> use enumeratevalue
- explicit
reflect == true
-> attempt to usevalue
member, error on it missing
from glaze.
After thinking about this more, I think it is best to not add pure enum reflection until supported by C++26 (hopefully).
Tagged enum values make this more complex. And, it bifurcates enum handling logic.
It isn't hard to add a using enum
statement and just copy the enum list into a glz::meta.
glz::meta also supports renaming enum values.
As cool as enum reflection would be, we don't want pure reflection as the default (integers are default). So, any additional reflection approach would be deprecated in the future. I'm less eager to add features that I know will have deprecated APIs.
from glaze.
Related Issues (20)
- The executable glaze_ide is built but not installed HOT 2
- Need more examples and improved documentation HOT 5
- Add support for unions (like variants) HOT 9
- Document current support and add more support for JSON Merge Patch
- `validate_json` returns `syntax_error` if buffer contains non-ASCII chars HOT 3
- Support 0 and 1 as boolean values HOT 1
- Bazel support HOT 2
- ASIO REPE example bad file descriptor error HOT 2
- minify_json compiler errors when including header directly HOT 5
- Function signatures inconsistency between write_file_json and read_file_json HOT 2
- Stack overflow when returning intermediate object to serialize in_addr HOT 6
- Bug: Malformed JSON string produced HOT 10
- Build and test for 32-bit in Actions
- std::pair arrays roundtrip
- `float` member issue with `clang++-15` and `g++-12` HOT 3
- `json_test.cpp(7840): warning C4267: '=': conversion from 'size_t' to 'uint16_t', possible loss of data` HOT 1
- glz::reader/glz::writer for incremental reading/writing HOT 5
- Partial read for BEVE
- glz::raw without quotes question HOT 1
- Binary serialization of hidden members HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from glaze.