News for hackers. Stuff that matters.
Re:Problems with C++ exceptions by ignition on Wednesday November 12, 2025 @05:05AM (#45898349)
https://godbolt.org/z/363oqqKfv

  struct File_handle {
      static auto Create(std::string const & pp, const char *r) -> std::expected<File_handle, std::error_code> {
          auto p = fopen(pp.c_str(), r);
          if (!p) return std::unexpected(error_code_from_errno(errno));
          return File_handle{p};
      }
      ~File_handle() { fclose(p); }
  private:
      File_handle(FILE * f) : p{f} {} 
      FILE *p;
  };

There are no comments on this comment yet.