stephenberry / glaze

Extremely fast, in memory, JSON and interface library for modern C++
MIT License
984 stars 102 forks source link

Tuple routines not working as expected #1096

Open shiretu opened 3 weeks ago

shiretu commented 3 weeks ago

Hi,

Consider the following code snippet from the library, at which I have added some debugging:

using object_types = typename variant_types<T>::object_types;
std::cerr << "T: " << get_type_string<T>() << "\n";
std::cerr << "object_types: " << get_type_string<object_types>() << "\n";
std::cerr << "glz::tuple_size_v<object_types>: " << glz::tuple_size_v<object_types> << "\n";

the output looks like this:

T: std::variant<connected, std::variant<subscribed_v4_orderbook, subscribed_v4_subaccounts, subscribed_v4_trades>, std::variant<channel_data_v4_orderbook, channel_data_v4_trades>>
object_types: glz::tuplet::tuple<connected>
glz::tuple_size_v<object_types>: 1

That is not correct. Our input T type is a std::variant consisting of 3 types. last 2 types from this variant are themselves variants. The wanted output should have been:

object_types: glz::tuplet::tuple<connected, std::variant<subscribed_v4_orderbook, subscribed_v4_subaccounts, subscribed_v4_trades>, std::variant<channel_data_v4_orderbook, channel_data_v4_trades>>
glz::tuple_size_v<object_types>: 3
shiretu commented 3 weeks ago

Created this PR https://github.com/stephenberry/glaze/pull/1098 which also includes fixes for issue https://github.com/stephenberry/glaze/issues/1092