Getting started on <future>

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@112061 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant
2010-08-25 17:32:05 +00:00
parent ef0036c5aa
commit a652172d86
13 changed files with 376 additions and 0 deletions

63
src/future.cpp Normal file
View File

@@ -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