惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
AI
AI
博客园 - 三生石上(FineUI控件)
腾讯CDC
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Y
Y Combinator Blog
大猫的无限游戏
大猫的无限游戏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
雷峰网
雷峰网
NISL@THU
NISL@THU
S
Schneier on Security
T
Threatpost
T
Tenable Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
IT之家
IT之家
宝玉的分享
宝玉的分享
T
Tailwind CSS Blog
C
Cybersecurity and Infrastructure Security Agency CISA
P
Privacy & Cybersecurity Law Blog
I
Intezer
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
T
Threat Research - Cisco Blogs
SecWiki News
SecWiki News
AWS News Blog
AWS News Blog
博客园 - Franky
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Proofpoint News Feed
V
V2EX
Recorded Future
Recorded Future
Microsoft Security Blog
Microsoft Security Blog
S
Secure Thoughts
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
Apple Machine Learning Research
Apple Machine Learning Research
Project Zero
Project Zero
PCI Perspectives
PCI Perspectives
G
GRAHAM CLULEY
Help Net Security
Help Net Security
Cloudbric
Cloudbric
Recent Announcements
Recent Announcements
V
Visual Studio Blog
Hacker News: Ask HN
Hacker News: Ask HN
N
News and Events Feed by Topic
C
CERT Recently Published Vulnerability Notes
The Cloudflare Blog
Forbes - Security
Forbes - Security
C
Cisco Blogs
O
OpenAI News
www.infosecurity-magazine.com
www.infosecurity-magazine.com

Hacker News

Introducing Claude Opus 4.7 Qwen Studio The Future of Everything is Lies, I Guess: Where Do We Go From Here? GitHub - SeanFDZ/macmind: Single-layer transformer in HyperTalk for the classic Macintosh Show HN: Agent-cache – Multi-tier LLM/tool/session caching for Valkey and Redis Moving a large-scale metrics pipeline from StatsD to OpenTelemetry / Prometheus GitHub - Nightmare-Eclipse/RedSun: The Red Sun vulnerability repository GitHub - SethPyle376/hiraeth: Local AWS emulator focused on fast integration testing, with SQS support, SQLite-backed state, and a debug-friendly web UI. GitHub - macOS26/Agent: Any AI, replaces Claude Code, Cursor, OpenClaw. Over 18 LLM providers (Claude, OpenAI, Gemini, Ollama, Zai, HF, Qwen) wired into a native Mac app that writes code, builds Xcode projects, bumps versions, manages git, automates Safari, use AppleScript, JS or Accessibility, extend Agent! w/ MCP Servers, run tasks from your iPhone via Messages. YouTube now lets you turn off Shorts I Made a Terminal Pager Burgers | マクドナルド公式 Commands — HackerNews CLI documentation ChatGPT for Excel PiCore - Raspberry Pi Port of Tiny Core Linux Live Nation illegally monopolized ticketing market, jury finds Google Broke Its Promise to Me. Now ICE Has My Data. Founding Engineer at Adaptional | Y Combinator CRISPR takes important step toward silencing Down syndrome’s extra chromosome GitHub - saffron-health/libretto: The AI toolkit for building reliable browser automations US v. Heppner (S.D.N.Y. 2026) no attorney-client privilege for AI chats [pdf] Unexpected €54k billing spike in 13 hours: Firebase browser key without API restrictions used for Gemini requests Retrofitting JIT Compilers into C Interpreters IPv6 – Google The Accursèd Alphabetical Clock Cybersecurity Looks Like Proof of Work Now Fragments: April 14 Cal.com Goes Closed Source: Why AI Security Is Forcing Our Decision | Cal.com - Scheduling Software for Online Bookings Laravel raised money and now injects ads directly into your agent When moving fast, talking is the first thing to break Too much Discussion of the XOR swap trick – Heather Cafe Introduction to Spherical Harmonics for Graphics Programmers The Grand Line Building a Z-Machine in the worst possible language High-Level Rust: Getting 80% of the Benefits with 20% of the Pain GitHub - duguyue100/midnight-captain: Inspired by Midnight Commander, tailored to my taste. How to build a `git diff` driver · Jamie Tanna | Software Engineer Center for Responsible, Decentralized Intelligence at Berkeley The Local Universe’s Expansion Rate Is Clearer Than Ever, but Still Doesn’t Add Up - A new synthesis of astronomical measurements confirms a persistent mismatch that could point to physics beyond current models The air throughout our homes is infused with microplastics. But there are things you can do to breathe less of them The disturbing white paper Red Hat is trying to erase from the internet – OSnews The Future of Everything is Lies, I Guess: Annoyances ‘Abhorrent’: the inside story of the Polymarket gamblers betting millions on war Productive procrastination — Max van IJsselmuiden maps, territory and LMs 447 Terabytes per Square Centimetre at Zero Retention Energy: Non-Volatile Memory at the Atomic Scale on Fluorographane Show HN: Pardonned.com – A searchable database of US Pardons 20 Years on AWS and Never Not My Job The Seasons are Wrong Artemis II crew splashes down near San Diego after historic moon mission We gave an AI a 3 year retail lease in SF and asked it to make a profit | Andon Labs How a dancer with ALS used brainwaves to perform live On filing the corners off my MacBooks Installing every* Firefox extension OpenClaw’s memory is unreliable, and you don’t know when it will break Steve Blank Nowhere Is Safe Chimpanzees in Uganda locked in vicious 'civil war', say researchers watgo - a WebAssembly Toolkit for Go linux/Documentation/process/coding-assistants.rst at master · torvalds/linux GitHub - callumlocke/json-formatter: Makes JSON easy to read. Founding Product Engineer at Bild AI | Y Combinator A compelling title that is cryptic enough to get you to take action on it GitHub - Keychron/Keychron-Keyboards-Hardware-Design: Industrial design files for Keychron keyboards and mice. 100+ models with CAD assets in STEP, DXF, DWG, and PDF. Source-available, with commercial use allowed for original compatible accessories within the license terms. [ANNOUNCE] WireGuardNT v0.11 and WireGuard for Windows v0.6 Released 1D-Chess Helium Is Hard to Replace Cooperative Vectors Introduction | Evolve Keeping a Postgres queue healthy — PlanetScale Our response to the Axios developer tool compromise Do Americans read print books, e-books or audiobooks more? The Zettelkasten Method in Obsidian: A Practical Setup Guide Artemis II Is Competency Porn and We Are Starving For It WeakC4 Flight Viz — Cockpit View A Mexican surveillance giant you’ve never heard of is now watching the U.S. border Surelock: Deadlock-Free Mutexes for Rust RISC-V 101 – what is it and what does it mean for Canonical? | Ubuntu The Problem That Built an Industry How Much Linear Memory Access Is Enough? | Solidean Investigating Split Locks on x86-64 Simplest hash functions Sybilproof reputation mechanisms (2005) [pdf] What is a property? How Complex is my Code? Static code analysis in Kotlin — tools overview Toffoli gates are all you need PGLite evangelism dcmake: a new CMake debugger UI Clojure on Fennel part one: Persistent Data Structures Fragments: April 2 Python Release Python install manager 26.1 The Life and Death of the Book Review - Liberties Introducing Database Traffic Control — PlanetScale Bitcoin miners are losing $19,000 on every BTC produced as difficulty drops 7.8% God sleeps in the minerals Building slogbox Apple Silicon and Virtual Machines: Beating the 2 VM Limit Who was “Not Even Wrong” first? Pokemon Evolution Vs Darwinian Evolution The APL Programming Language Source Code
Improvements to std::format in C++26
Marius Bancila · 2026-06-21 · via Hacker News

The C++26 standard features a series of improvements to the format library. In this article, we will look at the most important of them.

Printing an empty line

Prior to C++26, printing an empty line had to be done like this:

std::print("\n");

In C++26, std::println has an overload without any parameters that prints a new line to the console.

std::print();

Formatting pointers

Formatting pointer types was not available directly, it required a hack: reinterpreting the pointer type as an integer type in order to print it.

int i = 0;
const void* p = &i;

std::println("{:#018x}", reinterpret_cast<uintptr_t>(p));

In C++26, the formatting library supports formatting of pointer types directly:

  • implicitly, no specifier is required
  • explicitly, with wither the p (for lowercase) or P (for uppercase) specifiers

Null pointers are formatted as 0x0 (unless padding is specified).

Here are several examples of formatting pointers:

int i = 0;
const void* p = &i;
    
std::println("{}",     p);       // lowercase, the default           => 0x7fffb2715a54
std::println("{:p}",   p);       // explicit, same as none           => 0x7fffb2715a54
std::println("{:P}",   p);       // uppercase                        => 0X7FFFB2715A54
std::println("{:018}", p);       // zero-padded to width 18          => 0x00007fffb2715a54
std::println("{:>20}", p);       // right-aligned in a 20-wide field =>       0x7fffb2715a54
std::println("{}", nullptr);     //                                  => 0x0
std::println("{:016}", nullptr); //                                  => 0x00000000000000

Formatting paths

Another feature that required a workaround was printing paths from the std::filesystem namespace. You could use path::string() to get the string representation of a path.

namespace fs = std::filesystem;

fs::path p = "/usr/local/bin/clang++";
std::println("{}", p.string());

However, this prints the path unquoted. On the other hand, using the << operator would print the path in quotes:

std::cout << p << '\n';

C++26 adds a std::formatter for std::filesystem::path, which makes it easier to format paths.

  • by default, paths are formatted unquoted
  • the ? option defines a debug form which gives an escaped representation (in quotes)
  • the g option forces generic (forward-slash) separators (which mainly shows up on Windows)
fs::path p = "/usr/local/bin/clang++";
std::println("{}",  p);   // /usr/local/bin/clang++
std::println("{:?}", p);  // "/usr/local/bin/clang++"
fs::path p = R"(C:\Users\marius\file.txt)";
std::println("{}",    w);  // C:\Users\marius\file.txt    (native separators)
std::println("{:g}",  w);  // C:/Users/marius/file.txt    (generic)
std::println("{:g?}", w);  // "C:/Users/marius/file.txt"  (generic + escaped)

A related issue solved along was Windows string representation of paths. std::filesystem::path stores its text in wchar_t encoded as UTF-16 (Windows native). But p.string() narrows it down to the active code page, rather than UTF-8 which is what the formatting library expects. The result was a non-ASCII path could get transcoded to gibberish. The C++26 std::formatter<std::filesystem::path> converts Windows native UTC-16 to UTF-8 using Unicode transcoding and avoiding code pages, therefore solving the problem. Ill-formed UTF-16 is replaced with U+FFFD by default, or escaped under {:?}.

constexpr std::format

In C++26, the formatting functions std::format, std::vformat, std::format_to, std::format_to_n, std::formatted_size, and their wide variants, plus the underlying pieces (the format context, std::basic_format_arg, std::basic_format_string, and the format member of the standard formatters) are constexpr.

This makes it possible to use static_assert for instance with std::format such as in the following examples:

static_assert(std::format("{} {}", 1, 2) == "1 2");

static_assert(sizeof(void*) == 8,
              std::format("expected 64-bit, pointer is {} bytes", sizeof(void*)));

This works because it relies on to_chars() overloads which have been made constexpr, but only for integral types. So it can be used with strings, integer types, bool, char, and pointers. But there are several limitations to this feature. The following are not supported:

  • floating-point types
  • chrono types
  • locale-aware formatting (using the L specifier – as in {:L}, makes the call non-constant)

For now, compile-time std::format covers integers, strings, and diagnostics well, with floating-point support waiting on a separate paper (P3652) to make the floating-point <charconv> functions constexpr.

std::runtime_format becomes std::dynamic_format

The format string of std::format or std::print must be a constant expression. For instance, you can write this:

std::println("{} = {}", "x", 13);

But you cannot write the following:

std::string strf = "{} = {}";
std::println(strf, "x", 13);

This is ill-formed because strf is only known at runtime, and therefore is not a constant expression. The workaround is to use std::vformat:

const char* key = "y";
int val = 13;
std::string strf = "{} = {}";

std::string s = std::vformat(strf, std::make_format_args(key, val));
std::println("{}", s);

There is a workaround for the workaround (it’s basically syntactic sugar for std::vformat), the formally known as std::runtime_format function, that returns an object that stores a dynamic format string directly usable in user-oriented formatting functions and can be implicitly converted to std::basic_format_string.

std::string strf = "{} = {}";
std::println(std::runtime_format(strf), "x", 13);

In the final version of C++26, this has been simply renamed to std::dynamic_format (although at this time the compilers that do support it still use the previous name). Therefore, the snippet above now becomes:

std::string strf = "{} = {}";
std::println(std::dynamic_format(strf), "x", 13);

std::dynamic_format is constexpr, which means it can be used in constant-evaluation contexts, such as in the following example:

constexpr auto make_string = [](std::string_view f) {
    return std::format(std::dynamic_format(f), 1, 2);
};
static_assert(make_string("{}+{}") == "1+2");

See more

You can learn more about these changes from the following articles: