Take the following snippet as a base:
template<typename Type1, typename Type2>
auto Foo() {
std::tuple<std::shared_ptr<Type1>, std::shared_ptr<Type2>> example;
}
How should I go about creating my tuple of shared pointers when using a variadic template?
template<typename... Types>
auto Foo() {
// How to create the tuple?
}
There are tons of tuple and variadic template related questions here. Some seem to address this (link1, link2), but still feel too convoluted (honestly, the answers went over my head, but may well be the simplest way).
My attempt used recursive templates and std::tuple_cat
, but this creates many "sub-tuples" along the way, which is far from ideal.
In short: is there a "simpler" or "more direct" approach to this problem? Something that doesn't require multiple functions, recursive calls and whatnot, kinda like std::tuple<std::shared_ptr<Types...>>
?