Skip to content

andrewstalin/optional

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

Optional a temporary solution until the с++17 release.

Example

Use in Windows

auto handle = ::CreateFile(path, FILE_GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr);
THROW_IF(handle == INVALID_HANDLE_VALUE, WIN32_ERROR("CreateFile"));

Use in Linux/Mac Os

auto fd = ::open(path, flags);
THROW_IF(fd == -1, POSIX_ERROR("open"));

ErrorOrValue example

int fun();

...

try
{
    return optional::ErrorOrValue<int>(fun());
}
catch(...)
{
    return optional::ErrorOrValue<int>(std::current_exception());
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published