C++ 概念: BitmaskType
来自cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
定义了一种类型,它可以被用来表示一组常数值或这些值的任何组合。这种特质的典型实现是整数类型,std::bitset,或枚举(范围和无作用域)额外的运算符重载.
Original:
Defines a type that can be used to represent a set of constant values or any combination of those values. This trait is typically implemented by integer types, std::bitset, or enumerations (scoped and unscoped) with additional operator overloads.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 要求
的位掩码类型支持有限数量的位掩码的元素,这是不同的值的位掩码类型,例如,对于任何一对Ci和Cj,Ci & Ci != 0和Ci & Cj == 0.
Original:
The bitmask type supports a finite number of bitmask elements, which are distinct values of the bitmask type, such that, for any pair Ci and Cj, Ci & Ci != 0 and Ci & Cj == 0.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
按位运算符operator&,operator|,operator^,operator~,operator&=,operator|=,并operator^=定义的位掩码类型的值,并有相应的内置运营商无符号整数相同的语义,如果是不同的整数位掩码元素两个权力.
Original:
The bitwise operators operator&, operator|, operator^, operator~, operator&=, operator|=, and operator^= are defined for values of the bitmask type and have the same semantics as the corresponding built-in operators on unsigned integers would have if the bitmask elements were the distinct integer powers of two.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
下面的表达式是良好的,任何BitsetType十
Original:
The following expressions are well-formed and have the following meaning for any BitsetType X
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
| X |= Y | 设置对象的X值Y
Original: sets the value Y in the object X The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| X &= ~Y | 清除对象的X值Y
Original: clears the value Y in the object X The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| X&Y != 0 | 表示的值Y被设置在对象的X
Original: indicates that the value Y is set in the object X The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
具有以下涵义。
的每个representible位掩码元素被定义作为constexpr位掩码类型值.
Original:
Each representible bitmask element is defined as a constexpr value of the bitmask type.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 用法
以下的标准库,能满足不同
BitmaskTypeOriginal:
The following standard library types satisfy
BitmaskType:The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
- std::ctype_base::mask
- std::ios_base::fmtflags
- std::ios_base::iostate
- std::ios_base::openmode
- std::regex_traits::char_class_type
- std::regex_constants::syntax_option_type
- std::regex_constants::match_flag_type
- std::launch,
依赖于一些特定的实施方案(例如int n = std::ios_base::hex),代码是不可移植的,因为std::ios_base::fmtflags不一定是隐式转换为int.
Original:
Code that relies on some particular implementation option (e.g. int n = std::ios_base::hex), is nonportable because std::ios_base::fmtflags is not necessarily implicitly convertible to int.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.