lundi 5 avril 2021

How to interpret this conditional statement with regard to std::errc

I was reading an example of how to use std::from_chars function here, when I came by the following if statment:

if(auto [p, ec] = std::from_chars(str.data(), str.data()+str.size(), result);
       ec == std::errc())
        std::cout << result << "\n" "p -> \"" << p << "\"\n";

Unfortunately I can not understand what ec == std::errc() means and how is it the condition. Does it mean that if ec (the possible error) is equal to default value of enum class errc the the following line should be executed? if so isn't that also an error?

Can someone please explain it to me?

Aucun commentaire:

Enregistrer un commentaire