microsoft / microsoft/wil

Add `wil::println()` - C++23's `std::println()` but for HANDLEs

Open
#492 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
3k
Forks
300
Avg merge
19h 12m
Merged PRs (30d)
1

Description

e.g (needs C++20):

void println(
  HANDLE handle,
  std::format_string<Args...> format,
  Args&&... args) {
  const auto buffer = std::format(format, std::forward<Args>(args)...) + '\n';
  DWORD bytesWritten = {};
  while (bytesWritten < buffer.size()) {
    const auto remaining = buffer.size() - bytesWritten;
    DWORD bytesWrittenThisBatch {};
    const auto result = WriteFile(
      handle,
      buffer.data() + bytesWritten,
      remaining,
      &bytesWrittenThisBatch,
      nullptr);
    if (!SUCCEEDED(result)) {
      throw std::system_error(result, std::system_category());
    }
    bytesWritten += bytesWrittenThisBatch;
  }
}

Would also probably want a wchar version taking an std::wformat_string

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the HANDLE-based println example in the issue and inspect the WIL repository for the appropriate utility entry point; no file or test is named. Confirm the C++20 formatting and WriteFile behavior, then determine how the wchar overload should fit. Done means both requested HANDLE-oriented forms are implemented and covered by the repository's applicable tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.