From: Oscar F. <of...@wa...> - 2002-12-02 22:36:44
|
"Esa Vuokko" <eiv...@bo...> writes: > Al Stevens wrote: > | I'm using 3.2. Try this one: > | > | #include <vector> > | #include <algorithm> > | > | int main() { > | std::vector<int> vi(10); > | std::vector<int>::iterator k; > | fill(k, k + 10, 0); > | } > | > | All the algorithm functions, when used with STL iterators, seem to be in > the > | global namespace. That's a bug. > > > It's called argument dependant name lookup aka Koenig > lookup. See 3.2.4 in standard. I thought that too, but Comeau differs: d:\des\cppExp>como --A --strict fill.cpp Comeau C/C++ 4.3.0.1 (Aug 21 2002 15:45:32) for MS_WINDOWS_x86 Copyright 1988-2002 Comeau Computing. All rights reserved. MODE:strict errors C++ "fill.cpp", line 7: warning: variable "k" is used before its value is set fill(k, k + 10, 0); ^ "fill.cpp", line 7: error: identifier "fill" is undefined fill(k, k + 10, 0); ^ 1 error detected in the compilation of "fill.cpp". Lately I'm being more confident on that compiler than on my knowledge of the standard :-( > In principle, it searches namespaces where arguments are > located for to find the function. This is quite nicely explained > by Herb Sutter here : > http://www.gotw.ca/gotw/030.htm Yea, the thing is pretty clear. I'll wait some time before reporting a bug to Comeau, though :-) It's somewhat suprising that an old compiler like egcs-2-91.66 does that thing right while all the other non-gcc compilers I have (KAI 4.0f, Comeau 4.3.0.1, Borland 5.5.1, Intel 7.0, MSVC++ 6.0SP4) fails. -- Oscar |