I am working with tuples and auto, and I am facing the following errors. What am I doing wrong?
#include <iostream>
#include <string>
#include <tuple>
struct Custom
{
enum {INT, STRING} tags;
union dummy {
std::string s;
uint64_t i;
};
};
int main()
{
std::tuple<std::string, uint64_t> xs = {"hello World", 45};
auto [str, i] = xs;
std::cout<<str<<" "<<i<<"\n"; // works fine
Custom c1 = {Custom::INT, 45}; // error: too many initializers for 'Custom'
std::tuple<std::string, Custom> xs1 = {"hello World", { Custom::Tag::INT ,45}}; // error: too many initializers for 'Custom'
auto [p1, p2] = xs1; // error: cannot be referenced -- it is a deleted function
}