Skip to content
/ librr Public

rr - A small header only library which helps to avoid exceptions.

License

Notifications You must be signed in to change notification settings

stnuessl/librr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

rr - result return

A very simple C++ header only library which helps to avoid exceptions by providing return wrapper types capable of holding either the return value or an error value.

Motivation

This library provides a decent mechanism for error reporting in the absence of exceptions (e.g. a project uses the -fno-exceptions flag) via return values. The intention is to avoid additional function arguments which are normally used in such scenarious and encapsulate them into a single return value.

Installation

Simply run:

    # make install

As this is a header only library you don't have to compile anything for this to work. Also if you want to use the library you just need to include the header files in your sources - no library linking required.

Use # make uninstall if you want to remove the files from your system.

General Notes

The library disables safety checks if the preprocessor directive "NDEBUG" is specified. This can introduce undefined behaviour if you call .take() serveral times on the same object. Also you are always supposed to check with .ok() if an value is present before .take() ing it.

Usage examples

The file src/test/main.cpp provides a lot of examples which should give the user a good overview how the two provided classes can be used. The examples can be run by calling $ make.

About

rr - A small header only library which helps to avoid exceptions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published