tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
real.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_COMPLEX_REAL_HPP
5#define TETL_COMPLEX_REAL_HPP
6
7#include <etl/_complex/complex.hpp>
8#include <etl/_concepts/floating_point.hpp>
9#include <etl/_concepts/integral.hpp>
10
11namespace etl {
12
13/// \ingroup complex
14template <typename T>
15[[nodiscard]] constexpr auto real(complex<T> const& z) noexcept(noexcept(z.real())) -> T
16{
17 return z.real();
18}
19
20/// \ingroup complex
21template <floating_point Float>
22[[nodiscard]] constexpr auto real(Float f) noexcept -> Float
23{
24 return f;
25}
26
27/// \ingroup complex
28template <integral Integer>
29[[nodiscard]] constexpr auto real(Integer i) noexcept -> double
30{
31 return static_cast<double>(i);
32}
33
34} // namespace etl
35
36#endif // TETL_COMPLEX_REAL_HPP
constexpr auto real(Integer i) noexcept -> double
Definition real.hpp:29
constexpr auto real(complex< T > const &z) noexcept(noexcept(z.real())) -> T
Definition real.hpp:15
constexpr auto real(Float f) noexcept -> Float
Definition real.hpp:22
Definition adjacent_find.hpp:9
A complex number.
Definition complex.hpp:20