I was using parameter packs before, and I like them a lot in principle! Unfortunately, for what I'm trying to do, I kept getting errors about parameter inference failures
More or less, I'm trying to define a labeled tree structure that can have a type T at the leaves, and I want to be able to construct those trees with minimal boilerplate:
my_tree_thing<outputs> get_outputs() const override {
return {
{"foo", this->foo},
{"bar", {
{"baz", this->baz},
}},
};
}
This already works just fine in my current setup; but I'm trying to switch from std::shared_ptr to std::unique_ptr for storing childen, and I'm running straight into this initializer_list issue.
Honestly, I'd love to use template parameter packs here, regardless of the shared_ptr issues. But for the above syntax to work out, it seems like I have to give enough concrete type information in the constructor for the compiler to decide "ah, these brackets are an initializer for this type". Parameter packs don't leave enough type information at either the caller or the callee to resolve the type.
Yes, I'm being stubborn about not having to decorate the syntax above with type names. But it works now, darn it! 😅