cxxomfort  rel.20211024
Simple backports for C++ - https://ryan.gulix.cl/fossil.cgi/cxxomfort/
Namespaces | Functions
valcomp.hpp File Reference

Implements a generic strcmp-like (three-way) comparator. More...

Namespaces

 cxxomfort
 Namespace of the cxxomfort library.
 

Functions

template<typename T , typename Less >
int valcmp (T const &v1, T const &v2, Less comp) CXXO_NOEXCEPTNOTHROW
 Compares two objects and returns a 3-state comparison result the way memcmp , strcmp do. More...
 

Detailed Description

Implements a generic strcmp-like (three-way) comparator.

Function Documentation

◆ valcmp()

int cxxomfort::impl::valcmp ( T const &  v1,
T const &  v2,
Less  comp 
)

Compares two objects and returns a 3-state comparison result the way memcmp , strcmp do.

Returns
0 if both arguments compare equal; otherwise a negative or a positive number if the first object compares "less" than the second or viceversa, respectively.
Exceptions
Nothing.This function assumes comparators don't throw.