Suppose I want to make an array of pairs:
std::array my_pairs{
std::pair{1.23, 1},
std::pair{3.14, 2},
std::pair{7.89, 3},
};
In different instantiations, the first type in the pairs will differ, and the number of elements will differ, but the second type in the pairs will remain the same.
Is there a way to use a deduction guide to avoid the need to write std::pair for each element?
template<typename T, std::size_t size>
using PairArray = std::array<std::pair<T, int>, size>;
// magic code goes here
PairArray my_pairs{
{1.23, 1},
{3.14, 2},
{7.89, 3},
};
Alternatively, could a helper function be defined to make it work?
template</* ??? */>
auto make_pair_array(/* ??? */) { /* ??? */ }
auto my_pairs = make_pair_array(
{1.23, 1},
{3.14, 2},
{7.89, 3}
);
8