These are chat archives for boostorg/hana

Nov 2016
Adi Shavit
Nov 22 2016 11:40
Hi folks, @ldionne

A question about Hana:
Say I want to incrementally collect data in a tuple (or an equivalent heterogeneous container), i.e. incrementally add another value (and type) to the tuple.

I could use std::tuple_cat but I would need to copy and store the result in a different local variable for each such cat.

I can’t use std::any since I won’t know the contained type. Is there such a way to extract the contained type of an any?

Is it possible to have a single local variable that supports such "insert"s preferably without copying?

Does Hana have such a facility?

One obvious way to do this is to incrementally serialize the data (e.g. to json) and reparse it later, but this seems a bit roundabout.

Adi Shavit
Nov 22 2016 12:54
I’ve made some more clarifications in the SO question.
Jason Rice
Nov 22 2016 17:49
@adishavit If you have to make the tuple incrementally there is no getting away from the copy/move of each element each time you append. You could definitely get rid of the "clutter" of moved from objects by breaking each of those //... operations into separate functions. IMO large multipurpose functions are a bit of a no-no anyways. :coffee:
The only reason you would need to make a tuple incrementally is if each of those operations depended on the results of the previous operations.
Adi Shavit
Nov 22 2016 17:56
It actually might.
The reason I wanted this is to collect data for later serialization e.g. to csv or json.
I wanted to serialize or the end and not throughout the process.