6 #ifndef UTILS_FUNCTIONAL_H 7 #define UTILS_FUNCTIONAL_H 18 const auto GetId = [](
const auto &obj) {
return obj.GetId(); };
24 const auto GetPtrId = [](
const auto &obj) {
return obj->GetId(); };
30 const auto OptValue = [](
const auto &obj) {
return obj.value(); };
36 const auto OptHasValue = [](
const auto &obj) {
return obj.has_value(); };
42 const auto Is = [](
const auto &obj)->
bool {
return obj; };
48 const auto IsNullptr = [](
const auto &obj)->
bool {
return obj ==
nullptr; };
54 const auto IsNotNullptr = [](
const auto &obj)->
bool {
return obj !=
nullptr; };
60 const auto IsEmpty = [](
const auto &obj)->
bool {
return obj.empty(); };
66 const auto IsNotEmpty = [](
const auto &obj)->
bool {
return !obj.empty(); };
72 const auto GetSize = [](
const auto &obj)->std::size_t {
return obj.size(); };
78 const auto GetFirst = [](
const auto &pair) {
return pair.first; };
84 const auto GetSecond = [](
const auto &pair) {
return pair.second; };
89 const auto IfNotNull = [](
const auto &obj_ptr,
const auto Func) {
if (obj_ptr !=
nullptr) { Func(*obj_ptr); } };
92 const auto GetX = [](
const auto &o) {
return o.x; };
95 const auto GetY = [](
const auto &o) {
return o.y; };
98 template<
typename TypeIn,
typename TypeOut>
99 const auto StaticCast = [](
const TypeIn &value) {
return static_cast<TypeOut
>(value); };
const auto GetY
Lambda function that return the x value of an object.
Definition: Functional.h:95
const auto GetSecond
Lambda function that returns the second element in a pair.
Definition: Functional.h:84
const auto OptHasValue
Lambda function that returns whether a std::optional has value.
Definition: Functional.h:36
const auto IfNotNull
Lambda function that performs a callback on an if it is nor null. Otherwise it ignores it...
Definition: Functional.h:89
const auto StaticCast
StaticCast a value to a different type.
Definition: Functional.h:99
const auto OptValue
Lambda function that gets std::optional's value.
Definition: Functional.h:30
Contains common lambda functions.
Definition: Functional.h:12
const auto GetSize
Lambda function that returns the size of an object.
Definition: Functional.h:72
const auto IsEmpty
Lambda function that returns whether the object is empty.
Definition: Functional.h:60
const auto GetPtrId
Lambda function that uses 'GetId' function to get object's id.
Definition: Functional.h:24
const auto GetX
Lambda function that return the x value of an object.
Definition: Functional.h:92
const auto Is
Lambda function that casts the object to bool.
Definition: Functional.h:42
const auto IsNullptr
Lambda function that return whether the object is null pointer.
Definition: Functional.h:48
const auto GetFirst
Lambda function that returns the first element in a pair.
Definition: Functional.h:78
const auto IsNotNullptr
Lambda function that return whether the object is not a null pointer.
Definition: Functional.h:54
const auto GetId
Lambda function that uses 'GetId' function to get object's id.
Definition: Functional.h:18
const auto IsNotEmpty
Lambda function that returns whether the object is not empty.
Definition: Functional.h:66