I have two tuples, each containing containers of different types.
std::tuple<containerA<typesA>...> tupleA;
std::tuple<containerB<typesB>...> tupleB;
So, as an example tupleA
might be defined like this:
std::tuple<list<int>, list<float>> tupleA;
The two containers, containerA
and containerB
are different types. typesA
and typesB
do not intersect. I want to sort the containers inside the tuples by their sizes, and be able to access them by their type. So, as an example
std::tuple<list<int>, list<float>> tupleA {{2}, {3.3f, 4.2f}};
std::tuple<deque<double>, deque<uint8_t>> tupleB {{2.0, 1.2, 4.4}, {}};
auto sortedArray = sort(tupleA, tupleB);
sortedArray == {deque<uint8_t>, list<int>, list<float>, deque<double>};
sortedArray.get<list<float>>() == {3.3f, 4.2f};
std::get<list<int>>(tupleA).push_back(4);
std::get<list<int>>(tupleA).push_back(5);
std::get<list<int>>(tupleA).push_back(6);
sortedArray = sort(tupleA, tupleB);
sortedArray == {deque<uint8_t>, list<float>, deque<double>, list<int>};
The most important part is that I have to store sortedArray
and that the sizes of the elements in the tuple may change. I have not been able to create such a sort
function. The actual syntax of accessing the sortedArray
is not important.
I tried to use naive indexes to the container data inside the sortedArray
, such as using std::pair<A, 1>
to refer to the second element in tuple A, however I can't access the information of the tuple through it because it is not a constexpr
Aucun commentaire:
Enregistrer un commentaire