40 public std::runtime_error {
43 : std::runtime_error(
"no such element")
75 Try(
const std::exception_ptr&
e)
79 Try(std::exception_ptr&&
e)
98 class = std::enable_if<
99 std::is_convertible<std::result_of<F()>,A>
::value,A> >
103 return Try<A>(std::forward<F>(f)());
104 }
catch (
const std::exception &) {
105 return Try<A>(std::current_exception());
113 template <
typename F,
115 #if __cplusplus >= 201402L
118 static std::function<Try<B>(
const Try<A>&)>
121 return [f](
const Try<A>& ta) {
156 return !(*
this == ta);
163 template <
typename F,
168 return flatMap([&f](
const A&){
return f(); });
175 template <
typename F,
176 class = std::enable_if<
177 std::is_convertible<std::result_of<F(const A&)>,
bool>
::value> >
182 if (std::forward<F>(f)(*
m_value))
return *
this;
184 }
catch (std::exception &) {
185 return Try<A>(std::current_exception());
196 template <
typename F,
201 return map(std::forward<F>(f)).flatten();
221 template <
typename Err,
227 fold(Err&& err, Val&& val)
const {
236 template <
typename F>
238 foreach(F&& f)
const {
256 template <
typename F,
262 else return std::forward<F>(f)();
269 template <
typename B,
285 template <
typename F,
292 }
catch (std::exception &) {
293 return Try<B>(std::current_exception());
304 template <
typename F,
307 class = std::enable_if<
308 std::is_base_of<typename TB::value_type,A>
::value> >
314 return std::forward<F>(f)();
321 template <
typename TB,
323 class = std::enable_if<
324 std::is_base_of<typename TB::value_type,A>
::value> >
327 return orElse([&tb](){
return tb; });
334 template <
typename F,
335 class = std::enable_if<
337 std::result_of<F(const std::exception&)>,A>
::value> >
355 template <
typename Err,
typename Val,
359 class = std::enable_if<std::is_base_of<TryBase,TC>
::value>,
360 class = std::enable_if<std::is_same<TB,TC>::value > >
364 std::forward<Err>(err),
365 std::forward<Val>(val));
366 return folded.flatten();
373 template <
typename F,
377 return map(std::forward<F>(f));
384 template <
typename F,
389 return flatMap(std::forward<F>(f));
396 template <
typename F,
401 return andThen(std::forward<F>(f));
412 template <
typename F,
Try< B > operator|(F &&f) const
Try< B > map(F &&f) const
Try< A > & operator=(Try< A > &&ta)
static std::function< Try< B >const Try< A > &)> lift(F f)
Try< A > filter(F &&f) const
Try(const std::exception_ptr &e)
TB transform(Err &&err, Val &&val) const
bool operator==(const Try< A > &ta) const
virtual void move(double dx, double dy, casacore::String system="")
Implements RegionShape::move.
virtual casacore::String type() const
Implements RegionShape::type.
Try< A > & operator=(const Try< A > &ta)
Instance methods.
B getOrElse_(const B &b) const
Try(std::exception_ptr &&e)
B fold(Err &&err, Val &&val) const
std::exception_ptr m_exception
std::unique_ptr< A > m_value
TB operator>>=(F &&f) const
const Double e
e and functions thereof:
TB orElse_(const TB &tb) const
TB operator>>(F &&f) const
static Try< A > from(F &&f)
Static methods.
TryBase exists to enable tests in Try template methods of whether Try::value_type is a Try type...
bool operator!=(const Try< A > &ta) const
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
Try< A > recoverWith(F &&f) const