From dae3481b28ad0bedd4c5b98385af499cbbe2a10b Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Wed, 25 Aug 2010 17:32:05 +0000 Subject: Getting started on llvm-svn: 112061 --- libcxx/src/future.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 libcxx/src/future.cpp (limited to 'libcxx/src') diff --git a/libcxx/src/future.cpp b/libcxx/src/future.cpp new file mode 100644 index 00000000000..f9547c6609e --- /dev/null +++ b/libcxx/src/future.cpp @@ -0,0 +1,63 @@ +//===------------------------- future.cpp ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "future" +#include "string" + +_LIBCPP_BEGIN_NAMESPACE_STD + +class _LIBCPP_HIDDEN __future_error_category + : public __do_message +{ +public: + virtual const char* name() const; + virtual string message(int ev) const; +}; + +const char* +__future_error_category::name() const +{ + return "future"; +} + +string +__future_error_category::message(int ev) const +{ + switch (ev) + { + case future_errc::broken_promise: + return string("The associated promise has been destructed prior " + "to the associated state becoming ready."); + case future_errc::future_already_retrieved: + return string("The future has already been retrieved from " + "the promise or packaged_task."); + case future_errc::promise_already_satisfied: + return string("The state of the promise has already been set."); + case future_errc::no_state: + return string("Operation not permitted on an object without " + "an associated state."); + } + return string("unspecified future_errc value\n"); +} + + +const error_category& +future_category() +{ + static __future_error_category __f; + return __f; +} + +future_error::future_error(error_code __ec) + : logic_error(__ec.message()), + __ec_(__ec) +{ +} + +_LIBCPP_END_NAMESPACE_STD -- cgit v1.2.3