FastLED 3.9.15
Loading...
Searching...
No Matches
utility.h
Go to the documentation of this file.
1#pragma once
3#include "fl/stl/noexcept.h"
4
5namespace fl {
6
15template <typename T = void> struct less {
23 constexpr bool operator()(const T &lhs, const T &rhs) const FL_NOEXCEPT {
24 return lhs < rhs;
25 }
26};
27
34template <> struct less<void> {
44 template <typename T, typename U>
45 constexpr auto operator()(T &&lhs, U &&rhs) const FL_NOEXCEPT
46 -> decltype(fl::forward<T>(lhs) < fl::forward<U>(rhs)) {
47 return fl::forward<T>(lhs) < fl::forward<U>(rhs);
48 }
49};
50
60template <typename T = void> struct greater {
68 constexpr bool operator()(const T &lhs, const T &rhs) const FL_NOEXCEPT {
69 return rhs < lhs; // Equivalent to lhs > rhs, works with types that only have operator<
70 }
71};
72
80template <> struct greater<void> {
90 template <typename T, typename U>
91 constexpr auto operator()(T &&lhs, U &&rhs) const FL_NOEXCEPT
92 -> decltype(fl::forward<U>(rhs) < fl::forward<T>(lhs)) {
93 return fl::forward<U>(rhs) < fl::forward<T>(lhs); // Equivalent to lhs > rhs
94 }
95};
96
97// Backward compatibility alias
98template <typename T> using DefaultLess = less<T>;
99
100} // namespace fl
constexpr T && forward(typename remove_reference< T >::type &t) FL_NOEXCEPT
Definition s16x16x4.h:234
less< T > DefaultLess
Definition utility.h:98
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NOEXCEPT
constexpr auto operator()(T &&lhs, U &&rhs) const FL_NOEXCEPT -> decltype(fl::forward< U >(rhs)< fl::forward< T >(lhs))
Function call operator that performs the greater-than comparison.
Definition utility.h:91
constexpr bool operator()(const T &lhs, const T &rhs) const FL_NOEXCEPT
Function call operator that performs the greater-than comparison.
Definition utility.h:68
Binary function object that returns whether the first argument is greater than the second.
Definition utility.h:60
constexpr auto operator()(T &&lhs, U &&rhs) const FL_NOEXCEPT -> decltype(fl::forward< T >(lhs)< fl::forward< U >(rhs))
Function call operator that performs the less-than comparison.
Definition utility.h:45
constexpr bool operator()(const T &lhs, const T &rhs) const FL_NOEXCEPT
Function call operator that performs the less-than comparison.
Definition utility.h:23
Binary function object that returns whether the first argument is less than the second.
Definition utility.h:15