tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
bit_not.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_BIT_NOT_HPP
5#define TETL_FUNCTIONAL_BIT_NOT_HPP
6
7#include <etl/_utility/forward.hpp>
8
9namespace etl {
10
11/// \brief Function object for performing bitwise NOT. Effectively calls `operator~` on type T.
12///
13/// https://en.cppreference.com/w/cpp/utility/functional/bit_not
14///
15/// \ingroup functional
16template <typename T = void>
17struct bit_not {
18 [[nodiscard]] constexpr auto operator()(T const& arg) const -> T
19 {
20 return static_cast<T>(~arg);
21 }
22};
23
24template <>
25struct bit_not<void> {
26 using is_transparent = void;
27
28 template <typename T>
29 [[nodiscard]] constexpr auto operator()(T&& arg) const noexcept(noexcept(~etl::forward<T>(arg)))
30 -> decltype(~etl::forward<T>(arg))
31 {
32 return ~etl::forward<T>(arg);
33 }
34};
35
36} // namespace etl
37
38#endif // TETL_FUNCTIONAL_BIT_NOT_HPP
Definition adjacent_find.hpp:9
constexpr auto operator()(T &&arg) const noexcept(noexcept(~etl::forward< T >(arg))) -> decltype(~etl::forward< T >(arg))
Definition bit_not.hpp:29
Function object for performing bitwise NOT. Effectively calls operator~ on type T.
Definition bit_not.hpp:17
constexpr auto operator()(T const &arg) const -> T
Definition bit_not.hpp:18