C Macro API Reference
The C macro API header <boost/outcome/experimental/result.h> consists of these macros:
BOOST_OUTCOME_C_DECLARE_RESULT(ident, T, E)- Declares to C a
basic_resulttype uniquely identified byident.Tis available at the member variable.value, andEis available at the member variable.error. BOOST_OUTCOME_C_RESULT(ident)- A reference to a previously declared
resulttype with uniqueident. BOOST_OUTCOME_C_RESULT_HAS_VALUE(r)- Evaluates to 1 (true) if the input
resulthas a value. BOOST_OUTCOME_C_RESULT_HAS_ERROR(r)- Evaluates to 1 (true) if the input
resulthas an error. BOOST_OUTCOME_C_RESULT_ERROR_IS_ERRNO(r)- Evaluates to 1 (true) if the input
result's error value is a code in the POSIXerrnodomain.
The above let you work, somewhat awkwardly, with any C-compatible
basic_result<T, E>. basic_result<T, E> is trivially copyable and
standard layout if its T and E are both so, and it has the C layout:
struct cxx_result_##ident
{
T value;
unsigned flags;
E error;
};
<system_error2> support
BOOST_OUTCOME_C_DECLARE_STATUS_CODE(ident, value_type)- Declares to C a status code type with domain
value_typeavailable at the member variable.value. Theidentmust be any identifier fragment unique in this translation unit. It is used to uniquely identify this status code type in other macros. BOOST_OUTCOME_C_STATUS_CODE(ident)- A reference to a previously declared status code type with unique
ident.
There is a high likelihood that C++ functions regularly called by C
code will return their failures either in erased system_code
or in posix_code (i.e. errno code domain). Via querying the
returned value using BOOST_OUTCOME_C_RESULT_ERROR_IS_ERRNO(r), one can determine
if the returned code is in the errno code domain, and thus can be
fed to strerror() and so on. Therefore there are
convenience macro APIs for those particular use cases.
BOOST_OUTCOME_C_DECLARE_RESULT_ERRNO(ident, T)- Declares to C a
basic_result<T, posix_code>type uniquely identified byident. BOOST_OUTCOME_C_RESULT_ERRNO(ident)- A reference to a previously declared
basic_result<T, posix_code>type with uniqueident. BOOST_OUTCOME_C_DECLARE_RESULT_SYSTEM(ident, T)- Declares to C a
basic_result<T, system_code>type uniquely identified byident. BOOST_OUTCOME_C_RESULT_SYSTEM(ident)- A reference to a previously declared
basic_result<T, system_code>type with uniqueident.



