A lot of the C++ code that I write on my mac do not compile when ported over to a machine that compiles with gcc for the reason that I didn't include the libraries.
For example, the following code compiles on with Clang even though I did not #include <memory>
, but does not compile in gcc. I assume it compiles in Clang because the iostream
explicitly/implicitly includes memory
? If so, why are the libraries set up differently between different compilers instead of having some conventional standard that's ubiquitous? I find Clang to be a lot more lax than g++, and I don't think it's beneficial because code is not immediately portable.
#include<iostream>
int main()
{
std::unique_ptr<int> d;
}