Comments (4)
I think this is an awesome approach, thanks for all your work on this! I'm planning to add support once some other features and fixes are completed, or I would be happy to merge a pull request.
I do think it would be a good idea to add a compile time option to disable private access for those who do not want it (or deem it dangerous). I think once the feature is implemented it will be more obvious where this should go.
from glaze.
@schaumb, I'm sure you've seen this post about a C++20 approach to private access: https://dfrib.github.io/a-foliage-of-folly/
I like how this approach does not use the stateful meta programming (tag approach). I'm curious what you think about this approach.
I experimented with private access support and I've decided to hold back from including it in Glaze directly. Libraries like yours can be used with Glaze (lambda wrappers in glz::meta are one approach), to expose private variables where needed.
Adding support directly within Glaze would reduce boilerplate, but it would make it so clean that I feel uncomfortable bypassing an intended design feature of C++. It is better to encourage users to use public APIs, accessors, and other intended design features normally.
I do think accessing private members is fantastic for certain use cases, such as third party library serialization, and for debugging. But, realizing that I could just bring in a library like yours and use it with Glaze makes me less inclined to add it here.
Thanks for your research and work into this!
from glaze.
Thanks for the link @stephenberry !
I didn't know this article before. The main concept behind my access_private_20 project is that no macros are needed for the members (unlike the original access_private and the linked accessprivate), and the interface is unified to one definition: access_private::access<MPTR>
(no const diff, etc).
These are impossible without the friend injection, or the name duplication (pre/post function declaration).
from glaze.
Makes sense, I really like your implementation and it being macro free. Your approach should get even cleaner when we get reflection in C++.
from glaze.
Related Issues (20)
- 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
- error: constructor priorities are not supported 3316 | const char* argv[]) HOT 3
- gcc and msvc compilation error with explicit constructors HOT 19
- Warnings & Errors in various configurations HOT 16
- rapidjson ĺŻšćŻ HOT 15
- How do I read an array of json objects in glaze? HOT 15
- field-based parse bifurcation HOT 1
- Add the library to nuget HOT 2
- Option to skip reading in null values
- calculate serialize size before serialization and serialize to pre-allocated memory HOT 4
- Option to use partial with char* or char[] HOT 3
- data_must_be_null_terminated issue HOT 1
- Raw char buffer handling HOT 1
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.