This adds a new function unpackTuple<T_1, T_2, ..., T_n> to Slice and ArrayIterator. It can be used to unpack values from an array given their types. Given a type a Extractor<T> is used to extract the type from a slice. Thus we can easily add more types and even user code can provide specializations for their types to extract them.
unpackTuple extracts the first n elements from a Slice and reads n elements from an ArrayIterator.
auto t = s.unpackTuple<std::string, int, bool, Slice>();
static_assert(std::is_same_v<decltype(t), std::tuple<std::string, int, bool, Slice>>);
Coverage decreased (-0.02%) to 96.409% when pulling 6ad6cf2c77ce6fcd41f65a93d0168fcd0007a499 on feature/unpack-tuple into 390fc4c8dfec7c70704b22b0eafafc5d1f08b44a on main.
This adds a new function
unpackTuple<T_1, T_2, ..., T_n>
toSlice
andArrayIterator
. It can be used to unpack values from an array given their types. Given a type aExtractor<T>
is used to extract the type from a slice. Thus we can easily add more types and even user code can provide specializations for their types to extract them.unpackTuple
extracts the firstn
elements from aSlice
and readsn
elements from anArrayIterator
.Supported types are:
std::string
std::is_artihmetic
)bool
StringRef
Slice
std::string_view
(c++17 only)As by-product it also adds
extract<T>
to slice.