iostream support

Header file iostream_support.hpp

namespace outcome_v2_xxx
{
    template <class R, class S, class P>
    std::istream& operator>>(std::istream& s, result<R, S, P>& v);

    template <class R, class S, class P>
    std::ostream& operator<<(std::ostream& s, result<R, S, P> const& v);

    template <class R, class S, class P>
    std::string print('hidden' const& v);

    template <class S, class P>
    std::string print('hidden' const& v);

    template <class R, class P>
    std::string print('hidden' const& v);

    template <class P>
    std::string print('hidden' const& v);

    template <class R, class S, class P, class N>
    std::istream& operator>>(std::istream& s, outcome<R, S, P, N>& v);

    template <class R, class S, class P, class N>
    std::ostream& operator<<(std::ostream& s, outcome<R, S, P, N> const& v);

    template <class R, class S, class P, class N>
    std::string print(outcome<R, S, P, N> const& v);
}

Function outcome_v2_xxx::operator>>

template <class R, class S, class P>
std::istream& operator>>(std::istream& s, result<R, S, P>& v);

Deserialise a result. Format is status_unsigned [value][error]. Spare storage is preserved.

Requires: That R and S implement operator>>.


Function outcome_v2_xxx::operator<<

template <class R, class S, class P>
std::ostream& operator<<(std::ostream& s, result<R, S, P> const& v);

Serialise a result. Format is status_unsigned [value][error]. Spare storage is preserved.

Requires: That R and S implement operator<<.

If you are printing to a human readable destination, use print() instead.


Function outcome_v2_xxx::print

template <class R, class S, class P>
std::string print('hidden' const& v);

Debug print a result into a form suitable for human reading. Format is value|error. If the error type is error_code, appends " (ec.message())" afterwards.


Function outcome_v2_xxx::print

template <class S, class P>
std::string print('hidden' const& v);

Debug print a result into a form suitable for human reading. Format is (+void)|error. If the error type is error_code, appends " (ec.message())" afterwards.


Function outcome_v2_xxx::print

template <class R, class P>
std::string print('hidden' const& v);

Debug print a result into a form suitable for human reading. Format is value|(-void).


Function outcome_v2_xxx::print

template <class P>
std::string print('hidden' const& v);

Debug print a result into a form suitable for human reading. Format is (+void)|(-void).


Function outcome_v2_xxx::operator>>

template <class R, class S, class P, class N>
std::istream& operator>>(std::istream& s, outcome<R, S, P, N>& v);

Deserialise an outcome. Format is status_unsigned [value][error][exception]. Spare storage is preserved.

Requires: That R, S and P implement operator>>.


Function outcome_v2_xxx::operator<<

template <class R, class S, class P, class N>
std::ostream& operator<<(std::ostream& s, outcome<R, S, P, N> const& v);

Serialise an outcome. Format is status_unsigned [value][error][exception]. Spare storage is preserved.

Requires: That R, S and P implement operator<<.

If you are printing to a human readable destination, use print() instead.


Function outcome_v2_xxx::print

template <class R, class S, class P, class N>
std::string print(outcome<R, S, P, N> const& v);

Debug print an outcome into a form suitable for human reading. Format is one of:

  1. value|error|exception

  2. { error, exception }

If the error type is error_code, appends " (ec.message())" after the error. Exception type is printed as one of:

  1. std::system_error code code(): what()

  2. std::exception: what()

  3. unknown exception