The return value fro flash.enable_protection is an integer, where 0 means success. So it must be compared to 0 to result in a true value for ret.
If flash.disable_protect() returns non-zero, then ret will be false, so there's no point in doing a std::to_string on ret. You would need an integer intermediate value if you wanted to print the error value.