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