STX  1.0.0
Classes | Namespaces | Functions | Variables
option_result.h File Reference
#include "stx/internal/panic_helpers.h"
#include "stx/internal/try.h"
Include dependency graph for option_result.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  stx::Some< T >
 
struct  stx::Option< T >
 
struct  stx::Ok< T >
 
struct  stx::Err< E >
 
struct  stx::Result< T, E >
 
struct  stx::NoneType
 
struct  stx::Some< T >
 
struct  stx::Ok< T >
 
struct  stx::Err< E >
 
struct  stx::Option< T >
 
struct  stx::Result< T, E >
 

Namespaces

 stx
 
 stx::internal
 
 stx::internal::option
 
 stx::internal::result
 

Functions

template<typename Tp >
Tp && stx::internal::option::unsafe_value_move (Option< Tp > &)
 
template<typename U , typename T >
STX_FORCE_INLINE constexpr bool stx::operator== (Some< U > const &cmp, Option< T > const &option)
 
template<typename U , typename T >
STX_FORCE_INLINE constexpr bool stx::operator!= (Some< U > const &cmp, Option< T > const &option)
 
template<typename T >
STX_FORCE_INLINE constexpr bool stx::operator== (NoneType const &, Option< T > const &option) noexcept
 
template<typename T >
STX_FORCE_INLINE constexpr bool stx::operator!= (NoneType const &, Option< T > const &option) noexcept
 
template<typename Tp , typename Er >
Tp && stx::internal::result::unsafe_value_move (Result< Tp, Er > &)
 
template<typename Tp , typename Er >
Er && stx::internal::result::unsafe_err_move (Result< Tp, Er > &)
 
template<typename U , typename T , typename E >
STX_FORCE_INLINE constexpr bool stx::operator== (Ok< U > const &cmp, Result< T, E > const &result)
 
template<typename U , typename T , typename E >
STX_FORCE_INLINE constexpr bool stx::operator!= (Ok< U > const &cmp, Result< T, E > const &result)
 
template<typename F , typename T , typename E >
STX_FORCE_INLINE constexpr bool stx::operator== (Err< F > const &cmp, Result< T, E > const &result)
 
template<typename F , typename T , typename E >
STX_FORCE_INLINE constexpr bool stx::operator!= (Err< F > const &cmp, Result< T, E > const &result)
 
template<typename T >
STX_FORCE_INLINE constexpr auto stx::make_some (T value) -> Option< T >
 
template<typename T >
STX_FORCE_INLINE constexpr auto stx::make_none () noexcept -> Option< T >
 
template<typename T , typename E >
STX_FORCE_INLINE constexpr auto stx::make_ok (T value) -> Result< T, E >
 
template<typename T , typename E >
STX_FORCE_INLINE constexpr auto stx::make_err (E err) -> Result< T, E >
 
template<typename T >
STX_FORCE_INLINE auto stx::some_ref (T &value) noexcept
 
template<typename T >
STX_FORCE_INLINE auto stx::ok_ref (T &value) noexcept
 
template<typename E >
STX_FORCE_INLINE auto stx::err_ref (E &value) noexcept
 

Variables

constexpr NoneType const stx::None {}
 value-variant for Option<T> representing no-value More...
 

Detailed Description

Author
Basit Ayantunde rlama.nosp@m.rrr@.nosp@m.gmail.nosp@m..com
Date
2020-04-16

Copyright (c) 2020 Basit Ayantunde

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

to run tests, use:

#include <iostream>
#include <string>
#include <string_view>
using std::move, std::string, std::string_view;
using namespace std::literals; // makes '"Hello"s' give std::string
// and '"Hello"sv' give std::string_view
Author
Basit Ayantunde rlama.nosp@m.rrr@.nosp@m.gmail.nosp@m..com
Date
2020-06-05

Copyright (c) 2020 Basit Ayantunde

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.