[Solved]What is the meaning of this syntax?



  • @
    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



  • 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



  • Thanks, I learn one more thing.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.