tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
bit_or.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_OR_HPP
5#define TETL_FUNCTIONAL_BIT_OR_HPP
6
7#include <etl/_utility/forward.hpp>
8
9namespace etl {
10
11/// \brief Function object for performing bitwise OR. Effectively calls
12/// operator| on type T.
13///
14/// https://en.cppreference.com/w/cpp/utility/functional/bit_or
15template <typename T = void>
16struct bit_or {
17 [[nodiscard]] constexpr auto operator()(T const& lhs, T const& rhs) const -> T
18 {
19 return lhs | rhs;
20 }
21};
22
23template <>
24struct bit_or<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_OR_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_or.hpp:29
Function object for performing bitwise OR. Effectively calls operator| on type T.
Definition bit_or.hpp:16
constexpr auto operator()(T const &lhs, T const &rhs) const -> T
Definition bit_or.hpp:17