"Ron AF Greve" <me@localhost> wrote:
Hi,
As the others said post code:
Ok, thanks to all of you, I'll post an exhaustive code then!
After fixing my code, now I am trying to do the other way round: from a
string to either a type or a vector. However, I cannot compile my code,
due to a "call to fromString(std::string &) is ambiguous":
#include <vector>
#include <string>
#include <iostream>
using namespace std;
template<class T> T fromString(string src)
{
return "output T" << endl;
};
template<class T> vector<T> fromString(string src)
{
return "output vector of T" << endl;
};
int main()
{
string s("3.1415");
cout << fromString<double>( s ) << endl;
return 0;
}
I hope my code is ok. I paid attention to specializing the call to the
template function, but as I said, I am learning C++ so I am still making
mistakes!
If I specialize the call with an explicit reference to a double output,
why is it still ambiguous?
Thanks & cheers!
--
Sensei@iPhone
first. Your posted code is buggy because of something like that: