title: std::filesystem::exists -- Do I need to check the std::error_code value if the function returns true?
body: <p><a href="https://en.cppreference.com/w/cpp/filesystem/exists" rel="nofollow noreferrer">std::filesystem::exists</a> is used to check &quot;if the given file status or path corresponds to an existing file or directory.&quot; In my code, I am using the definition with the following signature:</p>
  <pre class="lang-cpp prettyprint-override"><code>bool exists( const std::filesystem::path&amp; p, std::error_code&amp; ec ) noexcept;
  </code></pre>
  <p>My question is: if the function returns the boolean value <code>true</code>, do I still need to check the value of the error code <code>ec</code>? Or can I assume that, if <code>std::filesystem::exists</code> returns <code>true</code>, then there is no error and <code>(bool)ec</code> is <code>false</code>?</p>
  <p>For example, suppose I have the following:</p>
  <pre class="lang-cpp prettyprint-override"><code>std::error_code ec;
  std::filesystem::path fpath = &quot;fname&quot;;
  bool does_exist = std::filesystem::exists(fpath, ec);
  if (does_exist) {
      ...
  }
  </code></pre>
  <p>Is it necessary to check that <code>(bool)ec == false</code> within the <code>if (does_exist) { ... }</code> block?</p>