acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
λ.h
1// Created by camilo on 2025-04-21 04:00 <3ThomasBorregaardSørensen!!
2#pragma once
3
4//#include <type_traits>
5#include <functional>
6
7template < typename PREDICATE >
8std::invoke_result_t<PREDICATE> λsafe_return(PREDICATE predicate)
9{
10
11 std::invoke_result_t<PREDICATE> result;
12
13 try
14 {
15
16 result = predicate();
17
18 }
19 catch (::exception & exception)
20 {
21
22 ::debug() << exception << "safe_pointer got exception!! going to return nullptr";
23
24 }
25 catch (...)
26 {
27
28 ::exception exception(error_catch_all_exception, "could not get pointer");
29
30 ::debug() << exception << "safe_pointer got exception!! going to return nullptr";
31
32 }
33
34 return result;
35
36}