I want to be able to do the following:
#include <array>
struct blah { };
template<typename... Args>
constexpr auto foo(Args&&... args)
{
return std::array<blah, sizeof...(Args)>;
}
auto res = foo({}, {});
The following answers aren't satisfying: they just want to check that the parameter pack is of a single type, but I want to convert the values right to it in the arguments (else it does not work).
C++ parameter pack, constrained to have instances of a single type?
Parameter with non-deduced type after parameter pack
I also can't use initializer_list since I wouldn't be able to count the number of arguments to pass to the array
type. And I especially don't want to type foo(blah{}, blah{});
.
What are my possibilities ?
Aucun commentaire:
Enregistrer un commentaire