Skip to content

Permit unconditional use of Nullable::operatorT() #1472

@eddelbuettel

Description

@eddelbuettel

When adding Nullable::operatorT() as a more idiomatic version of the existing as() getter, we encountered six packages among the 3000+ tested which would not compile. With this issue, we will look more closely but it seems that for all these six cases it is due to Nullable() being used in context of a ternary C operator (conf ? yes : no) and the compiler complaining that the 'yes' and 'no' cases had different types.

Presumably this goes back to how the compiler (implictly) casts and having operatorT() opens the door for a compiler error of the "type of Nulllable<someObject> different from someObject" which a simple cast will avoid. (And if one does the more commonly used explicit form of if (obj.IsNotNull()) yes else no it does not even arise.)

So I plan to send (simple) PRs to the six packages, monitor adoption and we should able to remove the currently-used #if defined(...) guard about Nullable::operatorT() that makes it a limited opt-in, and possibly switch to an opt-out reversing the boolean logic. To be seen.

Per the reverse dependency check, the packages are

  • gdalraster (and @ctoney is already on top of things)
  • ieTest
  • localScore
  • scellpam
  • sorcering
  • statgenIBD

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions