blob: f9547c6609e59d082a87db5d2b7a0de032d48175 [file] [log] [blame]
Howard Hinnant96803d92010-08-25 17:32:05 +00001//===------------------------- 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
15class _LIBCPP_HIDDEN __future_error_category
16 : public __do_message
17{
18public:
19 virtual const char* name() const;
20 virtual string message(int ev) const;
21};
22
23const char*
24__future_error_category::name() const
25{
26 return "future";
27}
28
29string
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
50const error_category&
51future_category()
52{
53 static __future_error_category __f;
54 return __f;
55}
56
57future_error::future_error(error_code __ec)
58 : logic_error(__ec.message()),
59 __ec_(__ec)
60{
61}
62
63_LIBCPP_END_NAMESPACE_STD