I have the following code
#include <string_view>
#include <utility>
namespace std
{
template <typename T1, typename T2>
pair(T1 t1, T2 t2) -> pair<T1, T2>;
}
template<typename ... T>
struct node {};
template<typename head_t, typename ... tail_t>
struct node<head_t, tail_t ...>
{
node(const head_t& head, const tail_t& ... tail)
: head(head)
, tail(tail...)
{}
head_t head;
node<tail_t ... > tail;
};
template <typename... T>
node(T... t) -> node<T...>;
int main()
{
node n{
std::pair{std::string_view{"a"}, int{4}},
std::pair{std::string_view{"b"}, int{5}},
std::pair{std::string_view{"dqwd"}, node{
std::pair{std::string_view{"asdas"}, float{3.4}}
}
};
return 0;
}
which I compile with
g++ -Wall -Wextra -Wpedantic -std=gnu++17 -Wl,--wrap=malloc
My data structure is a recursive list of a std::pair with the first element of type std::string_view.
Now I want to get rid of std::pair and std::string_view in the initalization because they will always be the same type, how can I achieve this? e.g:
node n{
{"a", int{4}},
{"b", int{5}},
{"dqwd", node{
{"asdas", float{3.4}}
}
};