Howard Hinnant | 96803d9 | 2010-08-25 17:32:05 +0000 | [diff] [blame^] | 1 | //===------------------------- future.cpp ---------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "future" |
| 11 | #include "string" |
| 12 | |
| 13 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 14 | |
| 15 | class _LIBCPP_HIDDEN __future_error_category |
| 16 | : public __do_message |
| 17 | { |
| 18 | public: |
| 19 | virtual const char* name() const; |
| 20 | virtual string message(int ev) const; |
| 21 | }; |
| 22 | |
| 23 | const char* |
| 24 | __future_error_category::name() const |
| 25 | { |
| 26 | return "future"; |
| 27 | } |
| 28 | |
| 29 | string |
| 30 | __future_error_category::message(int ev) const |
| 31 | { |
| 32 | switch (ev) |
| 33 | { |
| 34 | case future_errc::broken_promise: |
| 35 | return string("The associated promise has been destructed prior " |
| 36 | "to the associated state becoming ready."); |
| 37 | case future_errc::future_already_retrieved: |
| 38 | return string("The future has already been retrieved from " |
| 39 | "the promise or packaged_task."); |
| 40 | case future_errc::promise_already_satisfied: |
| 41 | return string("The state of the promise has already been set."); |
| 42 | case future_errc::no_state: |
| 43 | return string("Operation not permitted on an object without " |
| 44 | "an associated state."); |
| 45 | } |
| 46 | return string("unspecified future_errc value\n"); |
| 47 | } |
| 48 | |
| 49 | |
| 50 | const error_category& |
| 51 | future_category() |
| 52 | { |
| 53 | static __future_error_category __f; |
| 54 | return __f; |
| 55 | } |
| 56 | |
| 57 | future_error::future_error(error_code __ec) |
| 58 | : logic_error(__ec.message()), |
| 59 | __ec_(__ec) |
| 60 | { |
| 61 | } |
| 62 | |
| 63 | _LIBCPP_END_NAMESPACE_STD |