Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:44:26

0001 // Copyright (c) 2023 Klemens D. Morgenstern
0002 //
0003 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0004 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0005 #ifndef BOOST_COBALT_ERROR_HPP
0006 #define BOOST_COBALT_ERROR_HPP
0007 
0008 #include <boost/cobalt/config.hpp>
0009 #include <boost/system/error_code.hpp>
0010 
0011 namespace boost::cobalt
0012 {
0013 
0014 enum class error
0015 {
0016   moved_from,
0017   detached,
0018   completed_unexpected,
0019   wait_not_ready,
0020   already_awaited,
0021   allocation_failed
0022 };
0023 
0024 
0025 struct cobalt_category_t final : system::error_category
0026 {
0027   cobalt_category_t() : system::error_category(0x7d4c7b49d8a4fdull) {}
0028 
0029 
0030   std::string message( int ev ) const override
0031   {
0032 
0033     return message(ev, nullptr, 0u);
0034   }
0035   char const * message( int ev, char * , std::size_t ) const noexcept override
0036   {
0037     switch (static_cast<error>(ev))
0038     {
0039       case error::moved_from:
0040         return "moved from";
0041       case error::detached:
0042         return "detached";
0043       case error::completed_unexpected:
0044         return "completed unexpected";
0045       case error::wait_not_ready:
0046         return "wait not ready";
0047       case error::already_awaited:
0048         return "already awaited";
0049       case error::allocation_failed:
0050         return "allocation failed";
0051       default:
0052         return "unknown cobalt error";
0053     }
0054   }
0055 
0056   const char * name() const noexcept override
0057   {
0058     return "boost.cobalt";
0059   }
0060 };
0061 
0062 BOOST_COBALT_DECL system::error_category & cobalt_category();
0063 BOOST_COBALT_DECL system::error_code make_error_code(error e);
0064 
0065 }
0066 
0067 template<> struct boost::system::is_error_code_enum<boost::cobalt::error>
0068 {
0069   static const bool value = true;
0070 };
0071 
0072 #endif //BOOST_COBALT_ERROR_HPP