forked from Research/WhisperCom
Dominik Meyer
cc002ebfbb
git-subtree-dir: libs/json git-subtree-split: f42a74b8f53cc308647123d49d33d1c8122e3f42
1.5 KiB
1.5 KiB
basic_json::operator<
bool operator<(const_reference lhs, const_reference rhs) noexcept,
template<typename ScalarType>
bool operator<(const_reference lhs, const ScalarType rhs) noexcept;
template<typename ScalarType>
bool operator<(ScalarType lhs, const const_reference rhs) noexcept;
Compares whether one JSON value lhs
is less than another JSON value rhs
according to the following rules:
-
If
lhs
andrhs
have the same type, the values are compared using the default<
operator. -
Integer and floating-point numbers are automatically converted before comparison
-
Discarded values a
-
In case
lhs
andrhs
have different types, the values are ignored and the order of the types is considered, which is:- null
- boolean
- number (all types)
- object
- array
- string
- binary
For instance, any boolean value is considered less than any string.
Template parameters
ScalarType
- a scalar type according to
std::is_scalar<ScalarType>::value
Parameters
lhs
(in)- first value to consider
rhs
(in)- second value to consider
Return value
whether lhs
is less than rhs
Exception safety
No-throw guarantee: this function never throws exceptions.
Complexity
Linear.
Example
??? example
The example demonstrates comparing several JSON types.
```cpp
--8<-- "examples/operator__less.cpp"
```
Output:
```json
--8<-- "examples/operator__less.output"
```
Version history
- Added in version 1.0.0.