Posts for C++

A criticism of std::embed (D1040) - Learned

Fri, Feb 8, 2019, ~400 Words

A few people responded to the criticism of D1040 on reddit, and clearly there are at least a few people who are keen to see std::embed move forward. The rebuttals were imprecise, which obviously makes understanding the commenters’ concerns more difficult. However, the discussion did clarify a few things for me.

Tags: programming, C++

Read more →

A criticism of std::embed (D1040)

Sat, Feb 2, 2019, ~1300 Words

One of the current proposals for changing C++ is D1040R4, which proposes adding a function called std::embed, which can load binary assets during compilation. My initial reaction to the proposal was that the author’s must have missed the existing solutions to this problem. That was hubris (sorry). The authors have indeed considered existing solutions, and the proposal is well written, but the motivation for this feature needs more thought. It is not clear that the existing solutions are insufficient, or if moving that functionality into the compiler would be a benefit.

Tags: programming, C++

Read more →

Easy file reading

Mon, Jan 1, 2018, ~1200 Words

The standard approach to reading files is some equivalent to calling the functions open, read (repeatedly), and close. This pattern repeats across languages. However, for simply accessing a sequence of bytes, there is another approach that provides a much nicer API for reading files – memory mapped files. Instead of managing read buffers, one can use the operating system’s virtual memory management (VMM) to page in data as required. Here, I would like to show an implementation for C++.

Tags: programming, C++

Read more →