This is a very fundamental question. Is there any benefit in using boost::optional in the following scenario:
int somefunction(boost::optional<const Param&> value = getDefaultParam()){
return value->dosomething();
}
or
int somefunction(boost::optional<const Param&> value){
if (!value)
value = getDefaultParam();
return value->dosomething();
}
as opposed to just doing this:
int somefunction(const Param& value = getDefaultParam()){
return value.dosomething();
}
This is for the specific case where I know that I am initializing the Param object to a default value. Can there be any benefit of using a boost::optional on Param to the API or the client of the API ?