concept < t in category c++

appears as: <T
Functional Programming in C++

This is an excerpt from Manning's book Functional Programming in C++.

For this, you’ll roll your own implementation called expected<T, E>. When a function returns a value of this type, it will clearly communicate that you expect a value of type T, but that you can also get an error of type E.

Imagine you want to create a function that takes a list of usernames and gives you a list of formatted full names. The implementation of that function would be identical to the one that works on optional values. The same goes for a function that uses expected<T, E> instead of std::optional<T>. This is the power that widely applicable abstractions such as functors bring you: you can write generic code that works unchanged in various scenarios.

As with std::optional<T>, if you haven’t encountered an error, expected<T, E> contains a value. Otherwise, it contains the information about the error.

Listing 10.6 Composing the expected monad
template <
    typename T, typename E, typename F,
    typename Ret = typename std::result_of<F(T)>::type    #1  
    >
Ret mbind(const expected<T, E>& exp, F f)
{
    if (!exp) {
        return Ret::error(exp.error());    #2  
    }

    return f(exp.value());    #3  
}

#1   f can return a different type, so you need to deduce it so you can return it.
#2   If exp contains an error, passes it on
#3   Otherwise, returns the result f returned