Skip to content

A coroutine promise type for std::optional<T> that enables early return.

Notifications You must be signed in to change notification settings

davidvodnik/OptionalCoroutine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

OptionalCoroutine

A coroutine promise type for std::optional<T> that enables early return.

Replaces manual checking:

std::optional<int> main() {
    std::optional<int> result = may_fail();
    if (!result.has_value())
        return {};
    int value = result.value();
    //...
}

With a single co_await expression:

std::optional<int> main() {
    int value = co_await may_fail();
    //...
}

About

A coroutine promise type for std::optional<T> that enables early return.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published