in following code:
#include <iostream>
#include <tuple>
template<typename T>
struct Container
{
std::string id;
T value;
Container(std::string id, T value) : id(id), value(value) {}
};
template<typename... T>
struct ElementCodec
{
std::tuple<T...> values;
ElementCodec(T... args) : values(args...) {}
};
template<typename... T> ElementCodec(T...) -> ElementCodec<T...>;
int main()
{
ElementCodec a { int { 5 }, double { 3. }, Container { "52", 7 } };
auto [x, y, container] = a.values;
std::cout << x << ", " << y << ", " << container.value << '\n';
}
After the specialization of the given code the tuple values
is of type std::tuple<int, double, Container<int>>
. What I'd like to do is decaying it to the type stored in the container, so std::tuple<int, double, int>
to make th access via container.value
not necessary.
Is this possible to do in c++17? I've been stuck on this problem for a while now and can't really find any ressources about this.