I want to assign a value for an optional.
#include <iostream>
#include <string>
#include <boost/optional.hpp>
int main()
{
boost::optional<int> x;
int y;
x = y;
if (not x)
{
std::cout<<"none";
}
else
{
std::cout<<"not none";
}
}
It will be not none though y is uninitialized, how should I proceed to get none for an optional if the right value was not initialized ? Thanks.
Aucun commentaire:
Enregistrer un commentaire