-
Notifications
You must be signed in to change notification settings - Fork 0
Utility
DryPerspective edited this page Oct 12, 2023
·
2 revisions
A recreation of the modern features of the <utility> header, not counting move semantics functions or tuple support. A small collection of useful functions.
| exchange | Replaces the argument with a new value, then returns the old value |
| as_const | Obtains a const reference to its argument |
| declval | Obtains a reference to its argument for use in an unevaluated context |
| cmp_equal cmp_not_equal cmp_less cmp_less_equal cmp_greater cmp_greater_equal |
Comparison functions for integer types without type conversion |
| in_range | Checks if a given integer value is in range of a given integer type. |
int main(){
int x = -5;
unsigned int y = 5;
Print(x > y); //Prints true due to promoting -5 to an unsigned type.
Print(dp::comp_greater(x,y)); //Prints false
Print(dp::in_range<unsigned int>(x)); //Prints false. -5 is not in range of an unsigned int.
}