Update coroutine_handle<P>::promise to reflect N4663.

This patch updates the promise() member to match the current spec.
Specifically it removes the non-const overload and make the return
type of the const overload non-const.

This patch also makes the ASSERT_NOT_NOEXCEPT tests libc++ specific,
since other implementations may be free to strengthen the specification.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@303895 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2017-05-25 18:52:34 +00:00
parent a42191c839
commit 0b958696f5
2 changed files with 5 additions and 11 deletions

View File

@@ -194,15 +194,9 @@ public:
return *this;
}
_LIBCPP_INLINE_VISIBILITY
_Promise& promise() {
return *reinterpret_cast<_Promise*>(
__builtin_coro_promise(this->__handle_, alignof(_Promise), false));
}
_LIBCPP_INLINE_VISIBILITY
_Promise const& promise() const {
return *reinterpret_cast<_Promise const*>(
_Promise& promise() const {
return *reinterpret_cast<_Promise*>(
__builtin_coro_promise(this->__handle_, alignof(_Promise), false));
}

View File

@@ -39,12 +39,12 @@ void do_test(coro::coroutine_handle<Promise>&& H) {
// FIXME Add a runtime test
{
ASSERT_SAME_TYPE(decltype(H.promise()), Promise&);
ASSERT_NOT_NOEXCEPT(H.promise());
LIBCPP_ASSERT_NOT_NOEXCEPT(H.promise());
}
{
auto const& CH = H;
ASSERT_SAME_TYPE(decltype(CH.promise()), Promise const&);
ASSERT_NOT_NOEXCEPT(CH.promise());
ASSERT_SAME_TYPE(decltype(CH.promise()), Promise&);
LIBCPP_ASSERT_NOT_NOEXCEPT(CH.promise());
}
}