Концепции 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 X
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 | устанавливает значение Y в объект X
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 | очищает значение Y в объект X
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.