Header with templated bitwise operators for enum class flags.
More...
#include <type_traits>
Go to the source code of this file.
|
| | estd |
| | Collection of useful templates.
|
| |
|
| template<typename T > |
| constexpr std::enable_if< estd::isEnumClassFlags< T >{}, T >::type | operator & (const T &left, const T &right) |
| | Bitwise AND operator. More...
|
| |
| template<typename T > |
| constexpr std::enable_if< estd::isEnumClassFlags< T >{}, T >::type | operator| (const T &left, const T &right) |
| | Bitwise OR operator. More...
|
| |
| template<typename T > |
| constexpr std::enable_if< estd::isEnumClassFlags< T >{}, T >::type | operator^ (const T &left, const T &right) |
| | Bitwise XOR operator. More...
|
| |
| template<typename T > |
| constexpr std::enable_if< estd::isEnumClassFlags< T >{}, T >::type | operator~ (const T &object) |
| | Bitwise NOT operator. More...
|
| |
| template<typename T > |
| constexpr std::enable_if< estd::isEnumClassFlags< T >{}, T & >::type | operator&= (T &left, const T &right) |
| | Bitwise AND assignment operator. More...
|
| |
| template<typename T > |
| constexpr std::enable_if< estd::isEnumClassFlags< T >{}, T & >::type | operator|= (T &left, const T &right) |
| | Bitwise OR assignment operator. More...
|
| |
| template<typename T > |
| constexpr std::enable_if< estd::isEnumClassFlags< T >{}, T & >::type | operator^= (T &left, const T &right) |
| | Bitwise XOR assignment operator. More...
|
| |
Header with templated bitwise operators for enum class flags.
Implementation based on Using Enum Classes as Bitfields
- Author
- Copyright (C) 2019 Kamil Szczygiel http://www.distortec.com http://www.freddiechopin.info
- License
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
◆ operator &()
Bitwise AND operator.
- Template Parameters
-
| T | is the type of enum class flags for which there exists a specialization of estd::isEnumClassFlags which inherits from std::true_type |
- Parameters
-
| [in] | left | is the object on the left-hand side of operator |
| [in] | right | is the object on the right-hand side of operator |
- Returns
- result of bitwise AND of left and right
◆ operator&=()
Bitwise AND assignment operator.
- Template Parameters
-
| T | is the type of enum class flags for which there exists a specialization of estd::isEnumClassFlags which inherits from std::true_type |
- Parameters
-
| [in] | left | is the object on the left-hand side of operator |
| [in] | right | is the object on the right-hand side of operator |
- Returns
- reference to left after it was assigned the result of bitwise AND of left and right
◆ operator^()
Bitwise XOR operator.
- Template Parameters
-
| T | is the type of enum class flags for which there exists a specialization of estd::isEnumClassFlags which inherits from std::true_type |
- Parameters
-
| [in] | left | is the object on the left-hand side of operator |
| [in] | right | is the object on the right-hand side of operator |
- Returns
- result of bitwise XOR of left and right
◆ operator^=()
Bitwise XOR assignment operator.
- Template Parameters
-
| T | is the type of enum class flags for which there exists a specialization of estd::isEnumClassFlags which inherits from std::true_type |
- Parameters
-
| [in] | left | is the object on the left-hand side of operator |
| [in] | right | is the object on the right-hand side of operator |
- Returns
- reference to left after it was assigned the result of bitwise XOR of left and right
◆ operator|()
Bitwise OR operator.
- Template Parameters
-
| T | is the type of enum class flags for which there exists a specialization of estd::isEnumClassFlags which inherits from std::true_type |
- Parameters
-
| [in] | left | is the object on the left-hand side of operator |
| [in] | right | is the object on the right-hand side of operator |
- Returns
- result of bitwise OR of left and right
◆ operator|=()
Bitwise OR assignment operator.
- Template Parameters
-
| T | is the type of enum class flags for which there exists a specialization of estd::isEnumClassFlags which inherits from std::true_type |
- Parameters
-
| [in] | left | is the object on the left-hand side of operator |
| [in] | right | is the object on the right-hand side of operator |
- Returns
- reference to left after it was assigned the result of bitwise OR of left and right
◆ operator~()
Bitwise NOT operator.
- Template Parameters
-
| T | is the type of enum class flags for which there exists a specialization of estd::isEnumClassFlags which inherits from std::true_type |
- Parameters
-
| [in] | object | is the object on which the operator will act |
- Returns
- result of bitwise NOT of object