#include <iostream>
#include <system_error>
#include <string>
class user_defined_error_category : public std::error_category {
public:
const char* name() const noexcept override
{
return "user defined error";
}
std::string message(int ev) const override
{
return "error message";
}
};
const std::error_category& user_defined_category()
{
static user_defined_error_category cat;
return cat;
}
int main()
{
const std::error_category& cat = user_defined_category();
std::cout << cat.name() << std::endl;
}