I came across a codebase that is fixed on C++11 features but implements std::make_unique
. That is been done extending namespace std
to add the feature if C++14 is not use, i.e. wrapping the implementation around
#if defined(__cplusplus) && __cplusplus < 201402L
namespace std {
...
}
#endif
I know that is undefined behavior to extend namespace std
(with some exception). Is the case above still acceptable or should it be avoided in any case?
No, this is forbidden—even though, via
#define make_unique ? ? ?
a conforming C++11 program can be quite sure that the library never mentions the name (outside of a stringization) and would thus be unable to detect the extension.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With