tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
less.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
3
4#ifndef TETL_FUNCTIONAL_LESS_HPP
5#define TETL_FUNCTIONAL_LESS_HPP
6
7#include <etl/_utility/forward.hpp>
8
9namespace etl {
10
11/// \brief Function object for performing comparisons. Unless specialised,
12/// invokes operator< on type T.
13/// https://en.cppreference.com/w/cpp/utility/functional/less
14template <typename T = void>
15struct less {
16 [[nodiscard]] constexpr auto operator()(T const& lhs, T const& rhs) const -> bool
17 {
18 return lhs < rhs;
19 }
20};
21
22template <>
23struct less<void> {
24 using is_transparent = void;
25
26 template <typename T, typename U>
27 [[nodiscard]] constexpr auto
28 operator()(T&& lhs, U&& rhs) const noexcept(noexcept(etl::forward<T>(lhs) < etl::forward<U>(rhs)))
29 -> decltype(etl::forward<T>(lhs) < etl::forward<U>(rhs))
30 {
31 return etl::forward<T>(lhs) < etl::forward<U>(rhs);
32 }
33};
34
35} // namespace etl
36
37#endif // TETL_FUNCTIONAL_LESS_HPP
Definition adjacent_find.hpp:9
constexpr auto operator()(T &&lhs, U &&rhs) const noexcept(noexcept(etl::forward< T >(lhs)< etl::forward< U >(rhs))) -> decltype(etl::forward< T >(lhs)< etl::forward< U >(rhs))
Definition less.hpp:28
Function object for performing comparisons. Unless specialised, invokes operator< on type T....
Definition less.hpp:15
constexpr auto operator()(T const &lhs, T const &rhs) const -> bool
Definition less.hpp:16