The payload

We define the code domain’s value_type – the payload to be transported by status codes using this code domain – to be a POSIX errno value, an integer line number and a const char pointer.

  // This is the value type for `file_io_error`. We add line number and source file path.
  struct value_type
    typename outcome_e::posix_code::value_type errcode;  // from POSIX, as we inherit from _posix_code_domain

    // Our additional payload
    int lineno;        // from __LINE__
    const char *file;  // from __FILE__
    // Could also place a backtrace of void *[16] here ...
View this code on Github

You will note that this is a TriviallyCopyable type, and so gains an implicit conversion to any status_code<erased<T>> where sizeof(T) >= sizeof(value_type).

error is however status_code<erased<intptr_t>>, and sizeof(intptr_t) < sizeof(value_type), so it is not possible to implicitly convert status codes from this domain into error. Instead, you must tell the compiler how to do the conversion, as we shall see later.