Skip to content

invert_mask descriptor inverts return value to true for unassigned elements #316

@aleksamilisavljevic

Description

@aleksamilisavljevic

According to the documentation:

* @return If the descriptor does not include grb::descriptors::structural
* nor grb::descriptors::structural_complement and if \a assigned
* is false, then the entry is ignored and uninterpreted, thus
* returning \a false.
* @return If the descriptor includes grb::descriptors::invert_mask,
* returns the negation of the dereferenced value of \a val
* which is first cast to a \a bool.
* @return Otherwise, returns the dereferenced value of \a val,
* cast to a \a bool.

However, if the descriptor invert_mask is set and assigned is set to false, then the return value will be true:

bool ret = false;
// if we request a structural mask, decide only on passed assigned variable
if( descriptor & descriptors::structural ) {
ret = assigned;
} else {
// if based on value, if there is a value, cast it to bool
if( assigned ) {
ret = static_cast< bool >( val[ offset ] );
}
// otherwise there is no value and false is assumed
}
// check whether we should return the inverted value
if( descriptor & descriptors::invert_mask ) {
return !ret;
} else {
return ret;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions