tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
sign.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_MATH_SIGN_HPP
5#define TETL_MATH_SIGN_HPP
6
7namespace etl::detail {
8
9template <typename T>
10[[nodiscard]] constexpr auto sign(T val)
11{
12 if (val < 0) {
13 return T(-1);
14 }
15 return T(1);
16}
17} // namespace etl::detail
18
19#endif // TETL_MATH_SIGN_HPP
Definition adjacent_find.hpp:9