mardi 29 août 2017

How can I return char array with boost::optional

I try to return simple array with boost::optional

boost::optional<const char *> foo () {
   char ar[100] = {};
   return boost::make_optional(true, ar);
}

and I got the following error:

could not convert ‘boost::make_optional(bool, const T&) with T = char [100]’ from ‘boost::optional’ to ‘boost::optional’ return boost::make_optional(true, ar);

How can I handle such confusion?

Aucun commentaire:

Enregistrer un commentaire