maybe

Synopsis

template <class T>
struct maybe_tag;

struct nothing;
template <class T> struct just;

Description

Algebraic data type with two constructors: just and nothing. It can be used represent an optional value. When it is used for error reporting, just represents success and nothing represents failure.

#include <mpllibs/metamonad/maybe.hpp>

Example

using boost::mpl::equal_to;
using boost::mpl::int_;

struct division_by_zero;

template <class A, class B>
struct divide :
  if_<
    equal_to<A, int_<0>>,
    nothing,
    just<divides<A, B>>
  >
  {};

[up]