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:
@@ -195,17 +195,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
_Promise& promise() {
|
_Promise& promise() const {
|
||||||
return *reinterpret_cast<_Promise*>(
|
return *reinterpret_cast<_Promise*>(
|
||||||
__builtin_coro_promise(this->__handle_, alignof(_Promise), false));
|
__builtin_coro_promise(this->__handle_, alignof(_Promise), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
|
||||||
_Promise const& promise() const {
|
|
||||||
return *reinterpret_cast<_Promise const*>(
|
|
||||||
__builtin_coro_promise(this->__handle_, alignof(_Promise), false));
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
_LIBCPP_ALWAYS_INLINE
|
_LIBCPP_ALWAYS_INLINE
|
||||||
static coroutine_handle from_address(void* __addr) noexcept {
|
static coroutine_handle from_address(void* __addr) noexcept {
|
||||||
|
|||||||
@@ -39,12 +39,12 @@ void do_test(coro::coroutine_handle<Promise>&& H) {
|
|||||||
// FIXME Add a runtime test
|
// FIXME Add a runtime test
|
||||||
{
|
{
|
||||||
ASSERT_SAME_TYPE(decltype(H.promise()), Promise&);
|
ASSERT_SAME_TYPE(decltype(H.promise()), Promise&);
|
||||||
ASSERT_NOT_NOEXCEPT(H.promise());
|
LIBCPP_ASSERT_NOT_NOEXCEPT(H.promise());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto const& CH = H;
|
auto const& CH = H;
|
||||||
ASSERT_SAME_TYPE(decltype(CH.promise()), Promise const&);
|
ASSERT_SAME_TYPE(decltype(CH.promise()), Promise&);
|
||||||
ASSERT_NOT_NOEXCEPT(CH.promise());
|
LIBCPP_ASSERT_NOT_NOEXCEPT(CH.promise());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user