tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
minus.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_MINUS_HPP
5#define TETL_FUNCTIONAL_MINUS_HPP
6
7#include <etl/_utility/forward.hpp>
8
9namespace etl {
10
11/// \brief Function object for performing subtraction. Effectively calls
12/// operator- on two instances of type T.
13/// https://en.cppreference.com/w/cpp/utility/functional/minus
14template <typename T = void>
15struct minus {
16 /// \brief Returns the difference between lhs and rhs.
17 [[nodiscard]] constexpr auto operator()(T const& lhs, T const& rhs) const -> T
18 {
19 return static_cast<T>(lhs - rhs);
20 }
21};
22
23template <>
24struct minus<void> {
25 using is_transparent = void;
26
27 /// \brief Returns the difference between lhs and rhs.
28 template <typename T, typename U>
29 [[nodiscard]] constexpr auto
30 operator()(T&& lhs, U&& rhs) const noexcept(noexcept(etl::forward<T>(lhs) - etl::forward<U>(rhs)))
31 -> decltype(etl::forward<T>(lhs) - etl::forward<U>(rhs))
32 {
33 return etl::forward<T>(lhs) - etl::forward<U>(rhs);
34 }
35};
36
37} // namespace etl
38
39#endif // TETL_FUNCTIONAL_MINUS_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))
Returns the difference between lhs and rhs.
Definition minus.hpp:30
Function object for performing subtraction. Effectively calls operator- on two instances of type T....
Definition minus.hpp:15
constexpr auto operator()(T const &lhs, T const &rhs) const -> T
Returns the difference between lhs and rhs.
Definition minus.hpp:17