J
Jason Heyes
Consider these two templates:
template <class T>
std::istream &operator>>(std::istream &is, T &object);
template <class T>
std::istream &operator>>(std::istream &is, SharedPtr<T> &ptr);
What will the compiler do when it sees the following code?
Foo foo;
cin >> foo;
I presume that the compiler will instantiate the template std::istream
&operator>>(std::istream &is, T &object) with Foo. How about this code?
SharedPtr<Bar> bar;
cin >> bar;
Now I am not sure of what choice the compiler will make. Will it instantiate
the first function or the second? Thanks.
template <class T>
std::istream &operator>>(std::istream &is, T &object);
template <class T>
std::istream &operator>>(std::istream &is, SharedPtr<T> &ptr);
What will the compiler do when it sees the following code?
Foo foo;
cin >> foo;
I presume that the compiler will instantiate the template std::istream
&operator>>(std::istream &is, T &object) with Foo. How about this code?
SharedPtr<Bar> bar;
cin >> bar;
Now I am not sure of what choice the compiler will make. Will it instantiate
the first function or the second? Thanks.