Re: templated function help
On Feb 4, 4:40 am, p...@lib.hu wrote:
Is isspace overloaded? How?
I tried this in Cameau Online:
#include <vector>
#include <algorithm>
#include <ctype.h>
void foo()
{
std::vector<char> v(10);
std::find_if(v.begin(), v.end(), isspace);
}
end it compiles clean. Also in MSVC2008. I even tried to
force it by adding
#include <locale>
using namespace std;
still compiles.
If you include <locale> and add "using namespace std", it's
guaranteed by the standard not to compile. And doesn't with g++
(but surprisingly does with Sun CC and VC++).
Without the "using namespace std", of course, you're guaranteed
not to see the functions in <locale>, regardless, so the
ambiguity is not present. You still get undefined behavior at
runtime, of course, but that's a different question.
(If you meant that as the overload, in the originally
mentioned case locale was definitely not included)
The standard explicitly allows C++ headers to include any other
header. It's fully legal for <vector> or <algorithm> to include
<locale>. (It would be fully legal for an implementation to
just have a single, precompiled header, with everything in it.)
[hmm, it would be so nice to have gcc online too... ]
Given its price, there doesn't seem to be any reason not to have
a local copy. (That's actually almost true for Comeau. The
difference is that because Comeau is licenced software, I don't
have a right to install it on machines where I work.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34