title: What should a void*/std::size_t function argument pair be changed to for an interface that writes binary files?
body: <p>The C++ core guidelines state many times that using <code>void*</code> as an argument is at best confusing and at worst error-prone. My favorite mention is at the end:</p>
  
  <p><a href="http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#to-do-unclassified-proto-rules" rel="nofollow noreferrer">C++ Core Guidelines: To-do: Unclassified proto-rules</a></p>
  
  <blockquote>
    <p>Anyone writing a public interface which takes or returns void* should have their toes set on fire.
    That one has been a personal favorite of mine for a number of years. :)</p>
  </blockquote>
  
  <p>That said:</p>
  
  <p>What should this function signature be changed to in order to comply with this suggestion? Currently it works with anything, that can be reinterpreted as a <code>const char*</code>:</p>
  
  <pre><code>bool writeBufferToFile(void* buffer, std::size_t size, const std::string&amp; filePath) const
  {
      namespace FS = std::filesystem;
      FS::path p(filePath);
      p.make_preferred();
      bool not_valid_path = FS::is_directory(p);
      bool invalid = not_valid_path;
      if(invalid) { return false; }
  
      std::ofstream ofs;
      ofs.open(p.string(), std::ios_base::binary);
      if(ofs)
      {
          ofs.write(reinterpret_cast&lt;const char*&gt;(buffer), size);
          return true;
      }
      return false;
  }
  </code></pre>