So I just noticed today that I don't need to declare the namespace for the sort
on my macbook.
The following code compilers on my mac, but not my on my linux workstation (which uses vanilla g++
)
#include <iostream>
#include <ctime>
#include <vector>
int main()
{
std::vector<int> vec{1,2,3}; //needs std:: to compile on both mac and linux
sort(vec.begin(), vec.end()); //doesn't need std:: to compile on mac
}
This is the information for my g++
compiler that compiles the above code with no issues.
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Does XCode do something behind the scenes that makes the sort function available without declaring its namespace? What is it doing, and why does it allow for this?
Aucun commentaire:
Enregistrer un commentaire