I have a question regarding the function template parameter type deduction procedure.
Take this example:
#include <vector>
#include <sstream>
#include <string>
#include <iterator>
#include <fstream>
int main()
{
std::ifstream file("path/to/file");
std::vector<int> vec(std::istream_iterator<int>{file},{}); // <- This part
return 0;
}
If I understand things correctly, the second parameter is deduced to be of type std::istream_iterator
of which the default constructor is called.
The appropriate std::vector
constructor is declared as:
template <class InputIterator>
vector (InputIterator first, InputIterator last,
const allocator_type& alloc = allocator_type());
Since the first parameter type is deduced as std::istream_iterator<int>
the second parameter is deduced as std::istream_iterator<int>
too and so the uniform initialization semantics can be applied. What I have no idea about is at what order the type deduction happens. I would really appreciate some info on this.
Thanks in advance!