Qt has its own boost :: an additional alternative?

Does Qt have its own boost :: optional, or should I just use boost :: optional?

+4
source share
4 answers

There is a qt-maybe template implemented on top of the Qt QVariant container, but not in the standard qt lib.

+2
source

Qt is of type "variant", but not the "optional" type. I think that boost::optionalis a reasonable choice.

+2
source

, QVariant , boost::optional. :

bool QVariant::isNull() const
bool QVariant::isValid() const
Type QVariant::type() 
static QVariant QVariant::fromValue(const T & value)
T QVariant::value()

So, you can wrap any type, check if the option is null or valid, or even get the type that will be used with the if or switch statement.

+2
source

There is no alternative for boost :: optional at present. You can also refer to this topic: boost :: an additional alternative in the C ++ standard library

+1
source

Source: https://habr.com/ru/post/1616052/


All Articles