Payload

Custom payloads

So far in this tutorial, type EC in result<T, EC> has always been a std::error_code or boost::system::error_code. With NoValuePolicy set to default_policy<T, EC, EP> , EC needs in fact to merely satisfy the trait is_error_code_available<T> for EC to be treated as if an error_code. Outcome specialises that trait for std::error_code and boost::system::error_code, hence they “just work”. If no specialisation exists, trait::is_error_code_available<EC> is true if there exists some ADL discovered free function make_error_code(EC). »

Upgrading the Filesystem TS

An Outcome based solution to the dual overload problem is straightforward: namespace filesystem2 { // Error code + paths related to a failure. Also causes ADL discovery to check this namespace. struct failure_info { std::error_code ec; path path1, path2; }; // Tell Outcome that failure_info is to be treated as a std::error_code inline const std::error_code &make_error_code(const failure_info &fi) { return fi.ec; } // Localise an outcome implementation specific to this namespace. »