vendredi 26 juillet 2019

Extending namespace std to implement make_unique when using C++11

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?

Aucun commentaire:

Enregistrer un commentaire