Allow to load and store between virtual datum and any tuple like type #143
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A virtual datum can be seen as a tuple/struct of references. This PR improves interoperability between a virtual datum
vd
and user defined structs:vd.loadAs<T>()
andT value = vd.load();
allow to load the referenced data represented by a virtual datum into a typeT
, ifT
adheres to the following requirement:T
is direct list-initializable from a sequence ofU...
orU&...
, where the packU
denotes the types referenced by the virtual datum. In other words, the expressionT{std::declval<U>()...}
must be valid.vd.store(const TupleLike& t);
allows to store a value of a tuple-like type into the referenced memory locations of the virtual datum. Requires:TupleLike
to by a type for whichstd::tuple_size_v<TupleLike>
andget<I>(std::declval<TupleLike>())
(forI
in [0;std::tuple_size_v<TupleLike>
[) are valid expressions.TupleLike
and recursively its data members are the same as the tuple sizes of the virtual datum and its sub-virtual datums.Examples are found in the unit tests. Motivating example: