Header file status_code_ptr.hpp

#include "status_code.hpp"

namespace system_error2
{
    template <class T, typename std::enable_if<is_status_code<T>::value, bool>::type = true>
    int make_status_code_ptr();

    template <class StatusCode, class U, typename std::enable_if<is_status_code<StatusCode>::value, bool>::type = true>
    StatusCode* get_if(int* v) noexcept;

    template <class StatusCode, class U, typename std::enable_if<is_status_code<StatusCode>::value, bool>::type = true>
    StatusCode const* get_if(int const* v) noexcept;

    template <class U>
    typename status_code_domain::unique_id_type get_id(int const& v) noexcept;
}

Function system_error2::make_status_code_ptr

template <class T, typename std::enable_if<is_status_code<T>::value, bool>::type = true>
int make_status_code_ptr();

Make an erased status code which indirects to a dynamically allocated status code.

This is useful for shoehorning a rich status code with large value type into a small erased status code like system_code, with which the status code generated by this function is compatible. Note that this function can throw due to bad_alloc.


Function system_error2::get_if

template <class StatusCode, class U, typename std::enable_if<is_status_code<StatusCode>::value, bool>::type = true>
StatusCode* get_if(int* v) noexcept;

If a status code refers to a status_code_ptr which indirects to a status code of type StatusCode, return a pointer to that StatusCode. Otherwise return null.


Function system_error2::get_if

template <class StatusCode, class U, typename std::enable_if<is_status_code<StatusCode>::value, bool>::type = true>
StatusCode const* get_if(int const* v) noexcept;

(error while parsing comment text: unkown command \overload)


Function system_error2::get_id

template <class U>
typename status_code_domain::unique_id_type get_id(int const& v) noexcept;

If a status code refers to a status_code_ptr, return the id of the erased status code’s domain. Otherwise return a meaningless number.