Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. [Solved]What is the meaning of this syntax?
Qt 6.11 is out! See what's new in the release blog

[Solved]What is the meaning of this syntax?

Scheduled Pinned Locked Moved C++ Gurus
3 Posts 2 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stereomatching
    wrote on last edited by
    #1

    @
    struct Private
    {
    inline Private(): type(Invalid), is_shared(false), is_null(true) { data.ptr = 0; }
    inline Private(const Private &other)
    : data(other.data), type(other.type),
    is_shared(other.is_shared), is_null(other.is_null)
    {}
    union Data
    {
    char c;
    int i;
    uint u;
    bool b;
    double d;
    float f;
    qreal real;
    qlonglong ll;
    qulonglong ull;
    QObject *o;
    void *ptr;
    PrivateShared *shared;
    } data;
    uint type : 30;
    uint is_shared : 1;
    uint is_null : 1;
    };
    @

    some codes from QVariant, I have no idea what is the meaning of

    @
    uint type : 30;
    uint is_shared : 1;
    uint is_null : 1;
    @

    Thanks

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hpollak
      wrote on last edited by
      #2

      Looks like definition of BIT-Fields

      See:

      "Wikipedia":http://en.wikipedia.org/wiki/C++_classes

      scroll down to BIT Fields.

      So this means this 3 vars uses together 32Bit :

      type use 30 Bits
      is_shared use 1 Bit
      is_null use 1 Bit

      if the definition is without bit fields than:

      32 Bits for type
      32 Bits for is_shared and
      32 Bits for is_null

      1 Reply Last reply
      0
      • S Offline
        S Offline
        stereomatching
        wrote on last edited by
        #3

        Thanks, I learn one more thing.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved