'Wrapping external libraries in namespaces

I'm writing a library to use in my projects. In it, I was hoping to wrap the c standard library in my library's namespace and a cstd namespace to avoid having its functions in the global namespace. However, from a previous question I asked and from what I've tested, I can't just #include everything in a namespace. Is there any way to do this?



Solution 1:[1]

The usual approach would be to put the 3rd party includes in the implementation files to keep them from polluting your api.

myapi.hpp

void coolthing( int howcool );

myapi.cpp

#include <coollib.h>

void coolthing( int howcool )
{
    coollib_coolthing( howcool );
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 bob2