1 year ago
#329482
glades
How to elide type of temporary object in a variadic function call?
When is it possible to elide types of temporaries passed into a variadic function template? Overload resolution doesn't seem to work. Consider this:
#include <vector>
struct option
{
std::vector<int> to_wait;
std::vector<int> to_set;
};
namespace fsm
{
template <typename... Ts>
void generic_wait(Ts... Args) {
std::array<option, sizeof...(Ts)> hello = {{Args...}};
}
}
int main()
{
fsm::generic_wait(option{{2}, {3}}); // <-- This compiles
// fsm::generic_wait({{2}, {3}}); // <-- This I would like to compile
}
This compiles only when I directly specify the temporary type. If I leave it off it stops working (C++11). Can I do something to make it work?
c++11
variadic-functions
template-argument-deduction
temporary-objects
0 Answers
Your Answer