/usr/include/boost/outcome/experimental/status-code
NameSizeModeActions
detail/-0755rm
com_code.hpp92180644editdlrm
config.hpp161610644editdlrm
error.hpp26340644editdlrm
errored_status_code.hpp210120644editdlrm
generic_code.hpp190930644editdlrm
getaddrinfo_code.hpp63410644editdlrm
iostream_support.hpp30420644editdlrm
nt_code.hpp81400644editdlrm
posix_code.hpp67710644editdlrm
quick_status_code_from_enum.hpp78120644editdlrm
result.hpp139280644editdlrm
status_code.hpp254860644editdlrm
status_code_domain.hpp180670644editdlrm
status_code_ptr.hpp76810644editdlrm
status_error.hpp37410644editdlrm
std_error_code.hpp104940644editdlrm
system_code.hpp26660644editdlrm
system_code_from_exception.hpp42000644editdlrm
system_error2.hpp15790644editdlrm
win32_code.hpp89480644editdlrm
Edit: /usr/include/boost/outcome/experimental/status-code/status_code_ptr.hpp (7681B)
/* Pointer to a SG14 status_code (C) 2018-2020 Niall Douglas (5 commits) File Created: Sep 2018 Boost Software License - Version 1.0 - August 17th, 2003 Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following: The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef BOOST_OUTCOME_SYSTEM_ERROR2_STATUS_CODE_PTR_HPP #define BOOST_OUTCOME_SYSTEM_ERROR2_STATUS_CODE_PTR_HPP #include "status_code.hpp" BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE_BEGIN namespace detail { template class indirecting_domain : public status_code_domain { template friend class status_code; using _base = status_code_domain; public: using value_type = StatusCode *; using _base::string_ref; constexpr indirecting_domain() noexcept : _base(0xc44f7bdeb2cc50e9 ^ typename StatusCode::domain_type().id() /* unique-ish based on domain's unique id */) { } indirecting_domain(const indirecting_domain &) = default; indirecting_domain(indirecting_domain &&) = default; // NOLINT indirecting_domain &operator=(const indirecting_domain &) = default; indirecting_domain &operator=(indirecting_domain &&) = default; // NOLINT ~indirecting_domain() = default; #if __cplusplus < 201402L && !defined(_MSC_VER) static inline const indirecting_domain &get() { static indirecting_domain v; return v; } #else static inline constexpr const indirecting_domain &get(); #endif virtual string_ref name() const noexcept override { return typename StatusCode::domain_type().name(); } // NOLINT protected: using _mycode = status_code; virtual bool _do_failure(const status_code &code) const noexcept override // NOLINT { assert(code.domain() == *this); const auto &c = static_cast(code); // NOLINT return typename StatusCode::domain_type()._do_failure(*c.value()); } virtual bool _do_equivalent(const status_code &code1, const status_code &code2) const noexcept override // NOLINT { assert(code1.domain() == *this); const auto &c1 = static_cast(code1); // NOLINT return typename StatusCode::domain_type()._do_equivalent(*c1.value(), code2); } virtual generic_code _generic_code(const status_code &code) const noexcept override // NOLINT { assert(code.domain() == *this); const auto &c = static_cast(code); // NOLINT return typename StatusCode::domain_type()._generic_code(*c.value()); } virtual string_ref _do_message(const status_code &code) const noexcept override // NOLINT { assert(code.domain() == *this); const auto &c = static_cast(code); // NOLINT return typename StatusCode::domain_type()._do_message(*c.value()); } #if defined(_CPPUNWIND) || defined(__EXCEPTIONS) || defined(BOOST_OUTCOME_STANDARDESE_IS_IN_THE_HOUSE) BOOST_OUTCOME_SYSTEM_ERROR2_NORETURN virtual void _do_throw_exception(const status_code &code) const override // NOLINT { assert(code.domain() == *this); const auto &c = static_cast(code); // NOLINT typename StatusCode::domain_type()._do_throw_exception(*c.value()); } #endif virtual void _do_erased_copy(status_code &dst, const status_code &src, size_t /*unused*/) const override // NOLINT { // Note that dst will not have its domain set assert(src.domain() == *this); auto &d = static_cast<_mycode &>(dst); // NOLINT const auto &_s = static_cast(src); // NOLINT const StatusCode &s = *_s.value(); new(&d) _mycode(in_place, new StatusCode(s)); } virtual void _do_erased_destroy(status_code &code, size_t /*unused*/) const noexcept override // NOLINT { assert(code.domain() == *this); auto &c = static_cast<_mycode &>(code); // NOLINT delete c.value(); // NOLINT } }; #if __cplusplus >= 201402L || defined(_MSC_VER) template constexpr indirecting_domain _indirecting_domain{}; template inline constexpr const indirecting_domain &indirecting_domain::get() { return _indirecting_domain; } #endif } // namespace detail /*! 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`. */ template ::value, bool>::type = true> // inline status_code::type>::type>> make_status_code_ptr(T &&v) { using status_code_type = typename std::decay::type; return status_code>(in_place, new status_code_type(static_cast(v))); } /*! 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. */ template ::value, bool>::type = true> inline StatusCode *get_if(status_code> *v) noexcept { if((0xc44f7bdeb2cc50e9 ^ typename StatusCode::domain_type().id()) != v->domain().id()) { return nullptr; } union { U value; StatusCode *ret; }; value = v->value(); return ret; } //! \overload Const overload template ::value, bool>::type = true> inline const StatusCode *get_if(const status_code> *v) noexcept { if((0xc44f7bdeb2cc50e9 ^ typename StatusCode::domain_type().id()) != v->domain().id()) { return nullptr; } union { U value; const StatusCode *ret; }; value = v->value(); return ret; } /*! 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. */ template inline typename status_code_domain::unique_id_type get_id(const status_code> &v) noexcept { return 0xc44f7bdeb2cc50e9 ^ v.domain().id(); } BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE_END #endif