Why template classes are defined in header files

Templates need to be instantiated by the compiler before actually compiling them into object code. This instantiation can only be achieved if the template arguments are known. Now imagine a scenario where a template function is declared in a.h, defined in a.cpp and used in b.cpp. When…

Compile clang against libstdc++ with C++11 support on a Mac

Introduction In the last few years, Apple has been moving from the GCC toolchain to the LLVM toolchain. Indeed, starting from OS X 10.9 (Mavericks) libc++ has become the default C++ runtime library, thus definitely dropping the support for the otherwise widely-used libstdc++. It is important to notice that,…