Reputation: 1117
This code compiles successfully, and that's because I am apparently using the "global namespace" version of actually i'm not sure?.tolower
(as opposed to either of the versions that live in <cctype>
or <locale>
)
#include <string>
#include <algorithm>
int main() {
std::string x = "FOO";
std::transform(x.begin(), x.end(), x.begin(), tolower);
}
My questions:
1) Where/how is this tolower
established exactly?
2) Can someone direct me to a list of all such "global namespace" functions?
I've actually spent a fair amount of time seeking an answer; apologies if this is obvious knowledge and I missed it.
Upvotes: 0
Views: 50
Reputation: 96669
Some compilers provide declarations from <c__>
headers (from C standard library) in both std::
and global namespace. As @chris said, this is allowed by the standard, but there are no guarantees. Thus, you should not rely on it.
Upvotes: 1