Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it OK to inject a specialization into the std namespace?

Tags:

In this article on defining your own extensions to ::std::error_code the author recommends this code:

namespace std
{
  template <>
  struct is_error_code_enum<http_error>
    : public true_type {};
}

in order to enable conversions from your own error constants to the system error type.

Is this reasonable? It always makes me nervous to put things into the std namespace. Is there a better way of accomplishing the goal? Failing all that, is there a part of the standard that says this is always OK to do?