Search code examples
c++qtnulldefaultqlist

NULL return value of type QList<float*>


I would like to return a default Null value for a method returning a QList<float*> (in case processing fails, I want to return).

How to build a Null QList<float*> properly?


Solution

  • In general, there's no such thing as a "null value" for non-pointer types. Options include:

    • Throw an exception on failure
    • Return an empty list, if that can never be a valid result
    • Return a nullable wrapper type, like boost::optional<QList> or std::pair<bool, QList>