Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      C++ named requirements:BitmaskType

      From cppreference.com
      <cpp‎ |named req
       
       
      C++ named requirements
       

      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.

      [edit]Requirements

      The bitmask type supports a finite number of bitmask elements, which are distinct non-zero values of the bitmask type, such that, for any pairCi andCj,Ci& Ci is nonzero andCi& Cj is zero. In addition, the value0 is used to represent an empty bitmask, with no values set.

      The bitwise operatorsoperator&,operator|,operator^,operator~,operator&=,operator|=, andoperator^= 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 following expressions are well-formed and have the following meaning for anyBitmaskType:

      Expression Meaning
      X|= Y sets the valueY in the objectX
      X&= ~Y clears the valueY in the objectX
      X& Y nonzero result indicates that the valueY is set in the objectX

      Each representable bitmask element is defined as aninline(since C++17)constexpr value of the bitmask type.

      [edit]Standard library

      The following standard library types satisfyBitmaskType:

      (since C++17)
      (since C++11)
      (since C++17)

      Code that relies on some particular implementation option (e.g.int n=std::ios_base::hex) is non-portable becausestd::ios_base::fmtflags is not necessarily implicitly convertible toint.

      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/named_req/BitmaskType&oldid=182086"

      [8]ページ先頭

      ©2009-2025 Movatter.jp