Skip to content

Result - Simple monad solution based on C++17 and policy based design

License

Notifications You must be signed in to change notification settings

HunMaDog/Result

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Result

Result - Simple monad solution based on C++17 and policy based design

    #include "result/result.hpp"

    #include <iostream>

    using Result = Result<int, std::string>;

    constexpr int forty_and_two{42};
    static std::string const error_string{"Bad wolf"};

    Result answer(int answer)
    {
        return forty_and_two == answer ? Result{answer} : Result{error_string};
    }

    int main()
    {
        auto ok_result = answer(forty_and_two);
        
        if(ok_result)
        {
            std::cout << ok_result.value() << '\n';
        }
    
        return 0;
    }

{}

About

Result - Simple monad solution based on C++17 and policy based design

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published