user2524973
user2524973

Reputation: 1117

Where/how is the global tolower defined and what other similar functions exist?

This code compiles successfully, and that's because I am apparently using the "global namespace" version of tolower (as opposed to either of the versions that live in <cctype> or <locale>) actually i'm not sure?.

#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

Answers (1)

HolyBlackCat
HolyBlackCat

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

Related Questions