Files
flatbuffers/tests
Adam Oleksy 5822c1c8dd Fix dereference operator of VectorIterator to structures (#8425)
For Vector or Array of structures the dereference operator of an
iterator returns the pointer to the structure. However, IndirectHelper,
which is used in the implementation of this operator, is instantiated
in the way that the IndirectHelper::Read returns structure by value.

This is because, Vector and Array instantiate IndirectHelper with
const T*, but VectorIterator instantiates IndirectHelper with T. There
are three IndirectHelper template definition: first for T, second for
Offset<T> and the last one for const T*. Those have different
IndirectHelper:Read implementations and (more importantly) return type.
This is the reason of mismatch in VectorIterator::operator* between
return type declaration and what was exactly returned.

That is, for Array<T,...> where T is scalar the VectorIterator is
instantiated as VectorIterator<T, T>, dereference operator returns T
and its implementation uses IndirectHelper<T> which Read function
returns T.
When T is not scalar, then VectorIterator is instantiated as
VectorIterator<T, const T *>, dereference operator returns const T * and
its implementation uses IndirectHelper<T> which Read function returns T.

The fix is done as follows:
* implement type trait is_specialization_of_Offset and
 is_specialization_of_Offset64,
* change partial specialization of IndirectHelper with const T * that
 it is instantiated by T and enabled only if T is not scalar and not
 specialization of Offset or Offset64,
* remove type differentiation (due to scalar) from Array..

The above makes the IndirectHelper able to correctly instantiate itself
basing only on T. Thus, the instantiation in VectorIterator correctly
instantiate IndirectHelper::Read function, especially the return type.
2025-05-17 22:01:09 -07:00
..
2025-02-10 20:25:03 -08:00
2025-02-10 20:25:03 -08:00
2025-01-09 21:30:01 -08:00
2023-05-11 18:14:27 -07:00
2025-02-10 20:25:03 -08:00
2025-02-10 20:25:03 -08:00
2025-02-10 20:25:03 -08:00
2022-10-21 14:30:04 -04:00
2025-01-24 18:16:10 +00:00
2025-02-10 20:25:03 -08:00
2025-02-10 20:25:03 -08:00
2024-11-18 17:31:19 +00:00
2022-08-28 16:54:58 -07:00
2023-05-11 18:14:27 -07:00
2022-08-28 16:54:58 -07:00
2022-08-28 16:54:58 -07:00
2023-05-11 18:14:27 -07:00
2023-09-17 10:21:58 -07:00
2023-09-29 07:40:02 -07:00
2021-12-02 21:29:19 -08:00
2021-12-02 21:29:19 -08:00
2025-02-10 20:25:03 -08:00
2021-11-19 17:01:48 -08:00
2025-02-10 20:25:03 -08:00
2023-05-11 18:14:27 -07:00
2023-05-31 11:52:05 -07:00
2025-02-10 20:25:03 -08:00
2025-02-10 20:25:03 -08:00
2022-09-10 12:36:51 -07:00
2023-05-09 09:16:30 -07:00
2022-08-28 16:54:58 -07:00