Utilities
Utilities header only library
func Namespace Reference

Contains common lambda functions. More...

Variables

const auto GetId = [](const auto &obj) { return obj.GetId(); }
 Lambda function that uses 'GetId' function to get object's id. More...
 
const auto GetPtrId = [](const auto &obj) { return obj->GetId(); }
 Lambda function that uses 'GetId' function to get object's id. More...
 
const auto OptValue = [](const auto &obj) { return obj.value(); }
 Lambda function that gets std::optional's value. More...
 
const auto OptHasValue = [](const auto &obj) { return obj.has_value(); }
 Lambda function that returns whether a std::optional has value. More...
 
const auto Is = [](const auto &obj)->bool { return obj; }
 Lambda function that casts the object to bool. More...
 
const auto IsNullptr = [](const auto &obj)->bool { return obj == nullptr; }
 Lambda function that return whether the object is null pointer. More...
 
const auto IsNotNullptr = [](const auto &obj)->bool { return obj != nullptr; }
 Lambda function that return whether the object is not a null pointer. More...
 
const auto IsEmpty = [](const auto &obj)->bool { return obj.empty(); }
 Lambda function that returns whether the object is empty. More...
 
const auto IsNotEmpty = [](const auto &obj)->bool { return !obj.empty(); }
 Lambda function that returns whether the object is not empty. More...
 
const auto GetSize = [](const auto &obj)->std::size_t { return obj.size(); }
 Lambda function that returns the size of an object. More...
 
const auto GetFirst = [](const auto &pair) { return pair.first; }
 Lambda function that returns the first element in a pair. More...
 
const auto GetSecond = [](const auto &pair) { return pair.second; }
 Lambda function that returns the second element in a pair. More...
 
const auto IfNotNull = [](const auto &obj_ptr, const auto Func) { if (obj_ptr != nullptr) { Func(*obj_ptr); } }
 Lambda function that performs a callback on an if it is nor null. Otherwise it ignores it.
 
const auto GetX = [](const auto &o) { return o.x; }
 Lambda function that return the x value of an object.
 
const auto GetY = [](const auto &o) { return o.y; }
 Lambda function that return the x value of an object.
 
template<typename TypeIn , typename TypeOut >
const auto StaticCast = [](const TypeIn &value) { return static_cast<TypeOut>(value); }
 StaticCast a value to a different type.
 

Detailed Description

Contains common lambda functions.

Variable Documentation

◆ GetFirst

const auto func::GetFirst = [](const auto &pair) { return pair.first; }

Lambda function that returns the first element in a pair.

Note
applies to std::pair.

◆ GetId

const auto func::GetId = [](const auto &obj) { return obj.GetId(); }

Lambda function that uses 'GetId' function to get object's id.

Note
Applies to any object that has a GetId() function.

◆ GetPtrId

const auto func::GetPtrId = [](const auto &obj) { return obj->GetId(); }

Lambda function that uses 'GetId' function to get object's id.

Note
Applies to any pointer to an object that has a GetId() function.

◆ GetSecond

const auto func::GetSecond = [](const auto &pair) { return pair.second; }

Lambda function that returns the second element in a pair.

Note
applies to std::pair.

◆ GetSize

const auto func::GetSize = [](const auto &obj)->std::size_t { return obj.size(); }

Lambda function that returns the size of an object.

Note
Applies to any object that has a size() function. (std::vector...).

◆ Is

const auto func::Is = [](const auto &obj)->bool { return obj; }

Lambda function that casts the object to bool.

Note
Applies to all objects that can be cast/compared to bool.

◆ IsEmpty

const auto func::IsEmpty = [](const auto &obj)->bool { return obj.empty(); }

Lambda function that returns whether the object is empty.

Note
Applies to any object that has an empty() function. (std::vector, std::string...).

◆ IsNotEmpty

const auto func::IsNotEmpty = [](const auto &obj)->bool { return !obj.empty(); }

Lambda function that returns whether the object is not empty.

Note
Applies to any object that has an empty() function. (std::vector, std::string...).

◆ IsNotNullptr

const auto func::IsNotNullptr = [](const auto &obj)->bool { return obj != nullptr; }

Lambda function that return whether the object is not a null pointer.

Note
Applies to pointers.

◆ IsNullptr

const auto func::IsNullptr = [](const auto &obj)->bool { return obj == nullptr; }

Lambda function that return whether the object is null pointer.

Note
Applies to pointers.

◆ OptHasValue

const auto func::OptHasValue = [](const auto &obj) { return obj.has_value(); }

Lambda function that returns whether a std::optional has value.

Note
Applies to std::optional.

◆ OptValue

const auto func::OptValue = [](const auto &obj) { return obj.value(); }

Lambda function that gets std::optional's value.

Note
Applies to std::optional.