Function default_to

Synopsis

#include "breeze/vocabulary/maybe.hpp"

T default_to(T const &default_value) const

Description

Returns
value() if is_valid(); otherwise default_value.
Note that, differently from value(), this function returns by value, which prevents problems of dangling references. Note, too, that, for this reason, it is not noexcept (T's copy constructor might throw); a conditional noexcept() would be an option, but it adds too much complexity, in our opinion, and of course we would have to use it consistently, not just for default_to().

Source

Line 352 in breeze/vocabulary/maybe.hpp.