std::less_equals
Is a function object class used to perform comparisons. It is defined as a function object class for less than equality comparison that returns a Boolean value depending on the condition.
That is, just use the same example to order in ascending order:
Example:
Output:
2 4 8 9 11 12 13 17 52 79 89
Simple to understand, right?! That is, put in order of less than or equal.
std::variant
and std::visit
The std::variant
is as its name assumes, the type can vary, it is not the same as using auto
(needs initialization and cannot change type). That is, with std::variant
you can say that the var
variable can be: int
, std::string
, char *
,…
Std::visit is the way we will handle this data delivered by std::variant, that is, when you create a function it has a return type, so std::visit is almost the same idea directly linked to polymosphism. It is often used in conjunction with lambda expressions.
Example: Create a variable and pass its value to a function, in this case: lambda.
Some things to look at in the code above:
std::variant
;var
variable: int
, std::string
and char *
;std::visit
and once only: visit
;Well, for a quick and easy-to-understand analysis this is it! If you want to go deeper I suggest these links: std::less_equal, std::variant and std::visit .
That’s all for today, small daily doses that will always keep us in tune with C++!