C++17 introduces template argument deduction.
With gcc-7.2, I can use it easily in a function:
int test() {
std::pair d(0, 0.0);
}
I was expecting this same syntax to work in class non-static data members, like:
class Test {
std::pair d_{0, 0.0};
};
but this causes gcc error: invalid use of template-name ... without an argument list
, with --std=c++17
passed.
I tried a few other combinations, but none seems to work.
Is this the intended behavior by the standard, or is this a case of incomplete support by the compiler? I can't find any explicit reference to class data members in the standard.
My use case is of course much more complex, having this syntax would be extremely convenient (think functions being passed and stored).
See Question&Answers more detail:os