Defined in The verb object Call signatures Return value A monadic type of the same kind Examples struct Error final std string what fn expected<double Error> ex 12 1 auto rounded ex | fn and_then auto&& v > fn expected<unsigned Error> return static_cast<unsigned> std ceil v 0 5 REQUIRE rounded value 13u The resulting value is because does not contain an and therefore is called 13 ex Error and_then struct Error final std string what fn expected<double Error> ex fn unexpected<Error> Not good auto oops ex | fn and_then auto&& v > fn expected<unsigned Error> return static_cast<unsigned> std ceil v 0 5 Not called because ex contains an Error REQUIRE oops error what Not good The result is an because already contained an and therefore is not called Error ex Error and_then fn optional<double> op 12 1 auto rounded op | fn and_then auto&& v > fn optional<unsigned> return static_cast<unsigned> std ceil v 0 5 REQUIRE rounded value 13u The resulting value is because is not a and therefore is called 13 op nullopt and_then fn optional<double> op std nullopt auto empty op | fn and_then auto&& v > fn optional<unsigned> return static_cast<unsigned> std ceil v 0 5 Not called because op is empty REQUIRE not empty has_value The result is a because was already a and therefore is not called nullopt op nullopt and_then static constexpr auto parse std string_view str noexcept > fn choice_for<bool double long std string_view std nullptr_t std nullopt_t> if str size > 0 if str size > 1 && str 0 && str str size 1 return str substr 1 str size 2 else if str size > 1 && str 0 && str str size 1 return str substr 1 str size 2 else if str true return true else if str false return false else if str null return nullptr else if str find_first_not_of 01234567890 std string_view npos double tmp TODO switch to std from_chars when supported by libc std istringstream ss std string str data str size if ss >> tmp return tmp else long tmp auto const end str data str size if std from_chars str data end tmp ptr end return tmp return std nullopt return nullptr static_assert std is_same_v<decltype parse fn choice_for<bool double long std string_view std nullopt_t std nullptr_t>> CHECK parse abc fn choice std string_view abc CHECK parse R def fn choice std string_view def CHECK parse null fn choice nullptr CHECK parse fn choice nullptr CHECK parse true fn choice true CHECK parse false fn choice false CHECK parse 1025 fn choice 1025l CHECK parse 10 25 fn choice 10 25 CHECK parse 2e9 fn choice 2e9 CHECK parse 5e9 fn choice 5e9 CHECK parse foo has_value std in_place_type<std nullopt_t> Execute a function on the value of the monadic type if the value is present Use through the fn and_then nielbloid and_then_t and_then 1 Binds through a callable returning a carrier x | and_then f constexpr auto operator auto &&fn const > functor<and_then_t decltype fn > 1 Execute a function on the value of the monadic type if the value is present return A functor that will execute the function on the value fn auto && The function to execute on the value