libfxd 0.2.dev
A fixed-point library for C++.
Loading...
Searching...
No Matches
expect.hpp File Reference
#include <concepts>
#include "concepts.hpp"
#include "error.hpp"
#include "detail/safe.hpp"
#include "detail/safe-div.hpp"
#include "detail/safe-mul.hpp"
#include "detail/types.hpp"

Go to the source code of this file.

Namespaces

namespace  fxd
 This is the namespace where the entire library is defined.
 
namespace  fxd::expect
 Return fxd::expect::maybe<...> result.
 
namespace  fxd::expect::down
 Round down.
 
namespace  fxd::expect::up
 Round up.
 
namespace  fxd::expect::zero
 Round to zero.
 

Typedefs

template<typename T >
using maybe = detail::expected< T, error >
 Alias to std::expected, or an equivalent implementation.
 

Functions

template<int Int, int Frac, typename Raw = detail::select_int_t<Int + Frac>, std::convertible_to< fixed< Int, Frac, Raw > > Src>
constexpr maybe< fixed< Int, Frac, Raw > > make_fixed (Src src)
 Convenience overload.
 
template<int Int, int Frac, typename Raw = detail::select_uint_t<Int + Frac>, std::convertible_to< fixed< Int, Frac, Raw > > Src>
constexpr maybe< fixed< Int, Frac, Raw > > make_ufixed (Src src)
 Convenience overload (unsigned version).
 
template<int Int, int Frac, typename Raw = fxd::detail::select_int_t<Int + Frac>, fixed_point Src>
constexpr maybe< fixed< Int, Frac, Raw > > fixed_cast (Src src) noexcept
 Convenience overload.
 
template<int Int, int Frac, typename Raw = fxd::detail::select_uint_t<Int + Frac>, fixed_point Src>
constexpr maybe< fixed< Int, Frac, Raw > > ufixed_cast (Src src) noexcept
 Convenience overload (unsigned version).
 
template<fixed_point Dst, std::convertible_to< Dst > Src>
constexpr maybe< Dst > assign (Dst &dst, Src src) noexcept
 Assignment.
 
template<fixed_point Fxd>
constexpr maybe< Fxd > pre_inc (Fxd &f) noexcept
 Pre-increment (++f).
 
template<fixed_point Fxd>
constexpr maybe< Fxd > post_inc (Fxd &f) noexcept
 Post-increment (f++).
 
template<fixed_point Fxd>
constexpr maybe< Fxd > pre_dec (Fxd &f) noexcept
 Pre-decrement (--f).
 
template<fixed_point Fxd>
constexpr maybe< Fxd > post_dec (Fxd &f) noexcept
 Post-decrement (f--).