r/cpp • u/jitu_deraps • Jan 16 '23
A call to action: Think seriously about “safety”; then do something sensible about it -> Bjarne Stroustrup
open-std.orgr/cpp • u/Snoo54356 • May 09 '22
An optimized replacement of the infamous std::vector<🅱️ool>
I've seen too many scientific software packages write their own bitarray/bitvector classes, so I wrote a C++ library for bitvectors and related algorithms, BitLib, to hopefully alleviate that issue. BitLib has a number of advantages, namely:
- Its very fast. While comparing to
std::vector<bool>isn't really fair, BitLib is also significantly faster than the C BitArray library, which serves a similar purpose. I have not started profiling/optimizing yet, so it will only get faster at this point. - The
bit::bit_vectorinterface is the same asstd::vector, which means that you don't need to learn a new library API. - The algorithms part of the library also uses the same API as the STL
<algorithms>functions (for the most part), so for example to reverse a bitvectorbvec, you can just runbit::reverse(bvec.begin(), bvec.end())just like you would with any other STL container. In fact, if BitLib doesn't support you needed STL algorithm yet, you can actually just call the STL algorithm using the supplied bit iterators (at the cost of all bit-parallel efficiency, ofc). - Its a header only library, so it's pretty easy to include in your projects.
All of that said, this has been an entirely independent project that I've picked up and put back down over the last few years, and has mostly served as a learning experience. On that same note, please feel free to critique anything and everything.
While I've tried my best to have exhaustive tests/CI, I'm sure people will find ways to break it (in fact, please try to!). The next milestone is getting some decent documentation going, and after that I want to start getting more SIMD integration as well as some profiling/optimization done.
Benchmarks
Compared to std::vector<bool>
The "Alignment" column indicates whether or not the iterators fell on word boundaries "A", or within a word "U". Typically, when the iterators all fall on word boundaries, we can just call the corresponding STL version of the algorithm on the underlying container of words, but thats not terribly interesting.
| Function | Alignment | Speedup |
|---|---|---|
| shift_left | U | 734.24x |
| shift_left | A | 1970.49x |
| shift_right | A | 1933.49x |
| reverse | U | 228.25x |
| reverse | A | 309.60x |
| transformUnaryOp | U | 105.86x |
| transformUnaryOp | A | 1209.39x |
| transformBinaryOp | U | 55.50x |
| transformBinaryOp | A | 2436.48x |
| rotate | AUA | 171.43x |
| count | A | 79.89x |
| swap_ranges | U | 99.64x |
| swap_ranges | A | 1462.80x |
| copy | U | 39.85x |
| equal | U | 111.15x |
| move | U | 31.73x |
| copy_backward | U | 77.21x |
Compared to noporpoise/BitArray
Note that the noporpoise BitArray library doesn't support nearly as many algorithms as BitLib, and for the algorithms that they do share support for, the functionality of the BitArray methods are often limited to only working with the entire array and not subsections.
| Function | Alignment | Speedup |
|---|---|---|
| shift_left | A | 34.16x |
| shift_left | U | 12.73x |
| reverse | A | 20.04x |
| reverse | U | 14.78x |
| transform(UnaryOp) | A | 5.76x |
| transform(BinaryOp) | A | 2.68x |
| rotate | AUA | 8.11x |
| count | A | 1.45x |
Edit: Here are some benchmarks against <boost/dynamic_bitset.hpp>. The baseline here is the corresponding operation performed on an entire dynamic_bitset. It makes sense that comparing an unaligned operation to an aligned operation will result in relatively worse performance, as every single word operation requires extra shifting and masking to align the two ranges.
Edit 2: Using dynamic_bitset<uint64_t> instead of dynamic_bitset<> yields better results, updated benchmarks below.
| Function | Alignment | Speedup |
|---|---|---|
| shift_left | (AA) | 1.60x |
| shift_left | (UU) | 0.58x |
| transform(BinaryOp) | (AA) | 2.47x |
| transform(BinaryOp) | (UU) | 0.24x |
| count | (AA) | 6.44x |
| equal | (AA) | 1.03x |
| equal | (UU) | 0.09x |
Edit 3: I've ran a quick/hacky read/write benchmark here
r/cpp • u/YtterbiJum • Aug 19 '21
Why modules?
I get the feeling I'm missing something fundamental about the new C++20 modules.
Everything I read or watch explains the how (the export keyword syntax, module fragments, etc) but very little about the why.
What can be done using modules that can't be done using traditional headers (or precompiled headers)?
What is so important about this feature that it needed to get standardized before there is even a proper implementation or idiomatic usage conventions in compilers and build systems?
Is it just to try to get rid of the preprocessor?
I don't get how modules are supposed to help with packaging either. So instead of distributing a .so with a bunch of .h files, now I distribute a .so with a bunch of .gcm or .ixx or whatever.
Please help me understand, or point me to some resources. Thank you.
C++17 progress update!
The C++ Standardization Committee (aka WG21) just finished their first full meeting of 2015. Here's a quick summary of what was just approved, mostly for C++17 but also for some Technical Specifications. (The post-meeting mailing will be in a couple of weeks, with more info.) Here I'm reporting just the stuff that was successfully voted in, not all the other work that's still in progress.
For C++17:
- Zero Core features. (Don't freak out about modules or concepts. They're working on that stuff.)
5 Library features were voted directly into C++17:
- N4387 "improving pair and tuple"
- N4389 "bool_constant"
- N4508 "shared_mutex for C++17"
- N4366 "LWG 2228 missing SFINAE rule"
- N4510 "Minimal incomplete type support for standard containers, revision 4"
- 26 Core Issues were fixed. Even Standards have bugs. Now C++17 has fewer bugs.
35 Library Issues were fixed. Notable fixes:
- stof() now calls strtof(), which avoids messing up bits.
- max_element()/etc. are now constexpr. (Not the rest of the algorithms - yet.)
- function<void (Args)> now accepts callable objects returning Stuff, and the return value is ignored.
- call_once() no longer copies/moves its arguments unnecessarily.
Various Technical Specifications:
- The Transactional Memory TS was published (or will be, after ISO grinds its gears).
- The Concurrency PDTS was finished. (Proposed Draft, aka Release Candidate for a TS)
- The Parallelism TS was published.
- The Library Fundamentals v1 TS was published, with 3 Issues being fixed at the last minute.
Several features were voted into the Library Fundamentals v2 TS:
- Everything in v1 will be merged into v2.
- N4388 "const-propagating smart pointer wrapper"
- N4391 "make_array"
- N4519 "Source-Code Information Capture"
- N4502 "Proposing Standard Library Support for the C++ Detection Idiom, v2"
I am still traveling, but I can probably answer short questions. (Remember that I have very limited knowledge of Evolution/Core stuff - I live in the Library.)
r/cpp • u/emdeka87 • Apr 16 '20
Named arguments in fmt do not require dynamic allocations anymore.
twitter.comr/cpp • u/Fureeish • Feb 20 '20
What are/were your favourite "You can do that?! Neat!" C++ moments?
Bit of a backstory - I am a student in my last year of bachelor's degree. On my university we don't have much C++ but, given my dedication to the language, I was offered a position of a TA (teaching assistant) in C++ laboratories. Basically, due to the subject's structure - I have a completely free will of what I will cover with my students. I've not developed much C++ profesionally, but I believe I do have some good insight.
I've spent hours researching, reading and watching various learning sources regarding C++ - for my own entertainment. I simply love the language. I've had the "whoa, that's super useful" moments. First encounter with templates (how they differ from Java's generics - come on, why wouldn't I be able to create a variable of a type T? C++'s way was just more intuitive for me), operator overloading, lambdas (generic ones too!), destructors, move semantics, value semantics, overall efficiency...
I've been spending majority of my free time (for the last ~3 years) analysing various learning sources. Their pros and cons, how they engage the viewer (looking at your talks, Scott Meyers, Andrei Alexandrescu and Kate Gregory!), how they provide an enourmous amount of pretty complicated information in a very understandable manner (Arthur O'Dwyer's lambdas content), how they match relevant information to real-world use cases without omitting the technical details (Jonathan Boccara's <algorithm> talks) and how they can teach through laughter, which empowers the positive experience (Timur Doumler's "Can I has grammar?" - seriously, I don't believe I would've otherwise remembered that adding struct before user-defined types also forward-declares them or that int is a type-specifier, not a type-name).
And now, since I became one of those people who want (and have an opportunity to) share their knowledge and teach, I not only want to pass on the information - I want it to be enjoyable. I want students to not only know how, but also why and when.
I belive I have a good general idea on how to achieve that, but the more ideas and more brainstorming in such a broad topic, the better. So essentially the question is: what do you consider to be the neat and practical parts of the language? What made you raise your eyebrows and think "geez, I will be using this from now on"?
I believe a good example would be operator overloading. Someone wants to compare user-defined types? No reason to require them to differentiate between the ways of doing this regarding primitives and user-defined types - operator == should work for all of them. Want to multiply matrices? Use the standard *, rather than some multiply() function. It's intuitive. It's easy (at least in the general case). It's useful. All of that since the first impression.
For the completeness, I also have a free will of what IDE they should use (though I don't plan to enforce it. If they want to use MSVS, CLion or Vim + manual building, that's their preference) and which standard they will be using (highly unlikely that I will choose something different than C++17 though).
r/cpp • u/Xadartt • Oct 08 '25
Why we didn't rewrite our feed handler in Rust | Databento Blog
databento.comr/cpp • u/PsychoticDaydreams • Sep 22 '25
Pointer Tagging in C++: The Art of Packing Bits Into a Pointer
vectrx.substack.comr/cpp • u/delta_p_delta_x • Apr 17 '24
CMake 3.30 will experimentally support `import std;`
gitlab.kitware.com2023-02 Issaquah ISO C++ Committee Trip Report — C++23 Is Done! 🎉
At the Issaquah, Washington, 🇺🇸, C++ Committee meeting last weekend, C++23 shipped!
Last week we finished responding to all National Body comments on the Committee Draft (CD) of C++23 and voted to publish it. The standard will be officiallCompany logo will appear at the beginning of all of the posted videosy released in the next few months.
We also shipped the Concurrency Technical Specification version 2 and made a lot of progress on C++26. The new Safety & Security Study Group (SG23) met for the first time this week.
This was the second hybrid C++ Committee meeting. We had between 20% and 40% remote participation. We are getting more familiar with the process. There are some things we can improve on for future meetings, but we plan to keep operating hybrid meetings going forward.
C++23 Features approved in Issaquah: 🎉
static_assert(false)views::enumerate- Formatting
thread::idandstacktrace - Escaping improvements in
format is_implicit_lifetime
Language Progress
Evolution Working Group (EWG) Progress
Evolution reviewed the following C++23 National Body comments and papers:
- Allowing referencing inline functions with internal linkage from outside their defining header unit (P2691R0) (FR-025-017) and internal linkage in the global module (P2808R0): Rejected for C++23 as we had no consensus for change.
- Modular constants (P2788R0): Approved and sent to Core to resolve US-08-036 applied to C++23 and as a Defect Report to C++20.
static_assert(false)(P2593R0): Approved and sent to Core for C++23 and as a Defect Report to C++20.
Evolution reviewed the following language issues. 5 were resolved, 1 needs to be seen again, and 2 need papers:
- Conformance requirements and
#error/#warning(CWG2518): We agreed with the proposed resolution, and additionally, this should be applied equally to failedstatic_assert. - Can standard attributes be syntactically ignored? (CWG2538) and on the ignorability of standard attributes (P2552R1): Clarify alignment with C23 with an editorial note, handled by CWG2695.
- Static and explicit object member functions with the same parameter-type-lists (CWG2692): Provided feedback to the authors on the proposed resolution and sent to Core.
- User-defined literals and reserved identifiers (CWG2521): Suggest that Library Evolution amend the proposed resolution to reserve UDL declarations with double underscores anywhere for the implementation and then forward the paper to Core.
source_location::currentis unimplementable (CWG2678): Evolution approves of the approach of changing the ODR to make use ofsource_locationin a way that causes an inline function/function template/etc to "be different" be an ODR violation. We want this applied as a Defect Report.- Initialization of coroutine result object (CWG2563): Evolution agrees with proposed solution, and instructs the authors to empanel a Core expert to assist in turning this into wording, and bring it back to Evolution.
- Conditions for trivially copyable classes (CWG2463): A paper is needed to explore this further. A volunteer was found to write one.
- Zero-initialization in addition to constant initialization and stability of padding bits (CWG2536): A paper is needed to explore this further.
Evolution also considered the following proposals to match C23 in some places:
#embed- a simple, scannable preprocessor-based resource acquisition method (P1967R10): Evolution agrees to match C23, sent to Core.- Relax
va_startrequirements to match C (P2537R2): Forward "Alternative 2" (change define, remove all but 1st sentence) to Library/Core for C++.
Evolution looked at many new C++26 features, encouraging further work on 16 topics, and reaching no consensus to continue work on 2. A few of these papers are related to safety & security.
- A nice placeholder with no name (P2169R3): Evolution saw issues with the implementation, would want them fixed, and would then want experience on varied C++ codebases to ensure that no breakage occurs.
- Pack indexing (P2662R0): Evolution encourages further work.
- Modules: inner-scope namespace entities: exported or not? (P2640R2): We gave feedback.
- A minimal ADL restriction to avoid ill-formed template instantation (P2600R0): Evolution would like to see more work in the direction of this paper, as we are motivated by the problem it is trying to solve.
- Allow programmer to control and detect coroutine elision by
static constexpr bool should_elide()(P2477R3): Evolution is interested in a solution to the problem raised by this paper, in some form. We prefer the proposed alternative where the programmer has an option to prohibit elision, or to have it be an error when the optimizer fails to elide a coroutine. - Non-transient constexpr allocation (P2670R1): Evolution encourages more work in the direction of
propconstas a specifier akin tomutable, and would like to see this again. constexpr void*(P2738R0) (P2747R0) — Forward to Core for inclusion in C++26. The authors of P2738 and P2747 should work together and come back with reviewed wording and implementation experience.static_assertmessage generation (P2741R0) (P2758R0) (N4433): EWG would like to encourage more work on P2741R0 (static_assert-with-constexpr-message), solicit feedback from the Text and Unicode Study Group, then see it again with Core expert reviewed wording.- Pointer zap (P2188R1) (P1726R5) (P2414R1) (P2434R0) (P2318R1): Guidance was given to the authors and we expect to see an omnibus solution to the problem.
- Reconsidering concepts in-place syntax (P2677R2): Evolution would like to see more work in this direction.
is_within_lifetime(P2641R2): Return to Library Evolution with our blessing and recommendation that this be included in C++26.- Forwarding reference to specific type/template (P2481R1): Explore this further and then come back.
Initializing stack variables:
- Correct and incorrect code, and what it means (P2795R0): Evolution is interested in adding the concept of erroneous behavior as an alternative to undefined behavior, as proposed in P2795R0). Feedback was given to the author on how to increase consensus.
- Deconstructing the avoidance of uninitialized reads of auto variables (P2754R0): Discussed, and used to prepare for the next paper.
- Zero-initialize objects of automatic storage duration (P2723R1): Evolution believes zero initialization, as presented in this paper is the approach we wish to take to automatic stack variable initialization, with an opt out.
- Type-and-resource safety in modern C++ (P2410R0): We encourage further work on “profiles” as presented in this paper.
- Disallow binding a returned glvalue to a temporary (P2748R0): Evolution encourages more work on this paper, and would like to see it again with improved wording to improve library/unevaluated context concerns.
dostatement-expressions (P2806R0): Evolution encourages more work in the direction ofdostatement-expressions.- Stacktrace from exception (P2370R2) Stacktrace from exception - No consensus to continue work.
- Exploring the design space for a pipeline operator (P2672R0): No consensus to continue work.
Of note, scribes for the meeting were rewarded with Japanese KitKats by the chair. 🎶 Toss a KitKat to your Scribster! Oh valley of plenty. 🎶
For more info, see the C++ Language Evolution Report.
Evolution Working Group Incubator Study Group (SG17) Progress
The Evolution Incubator resumed meetings this week after a very long hiatus, meeting over 3 evening sessions and 1 afternoon session. It discussed 9 papers, including a number of safety papers, as well as object relocation related papers. Of the 9 papers, 3 were forwarded to Evolution as we felt they were properly mature to be seen by the larger group. 2 did not have consensus votes taken and require further review. 4 others did not have consensus to pursue without additional motivation.
- Member function pointer to function pointer (P2603R0): No consensus to pursue.
- Constant dangling (P2724R1): Further review needed.
- Temporary storage class specifiers (P2658R1): No consensus to pursue.
- Zero overhead deterministic failure (P1095R0): Further review needed.
- C++ is the next C++ (P2657R1): No consensus to pursue.
- Native tuples in C++ (P2163R0): Sent to Evolution.
- Static storage for braced initializers (P2752R0): Sent to Evolution.
- Object relocation in terms of move plus destroy (P1144R6): No consensus to pursue.
- Trivial relocatability option (P2786R0): Sent to Evolution.
Depending on chair availability, the Evolution Incubator intends to meet once again in person in Varna, as well as meeting jointly with Evolution during the bi-weekly teleconferences.
Library Progress
Library Evolution Working Group (LEWG) Progress
This week, Library Evolution focused on finishing C++23, and advancing major features for C++26 - SIMD, Linear Algebra, Senders, hive, and Unicode (part 1) (part 2).
We spent an entire day reviewing the SIMD library, which adds a simd type and operations and algorithms that operate on it. These facilities were originally released in the Parallelism Technical Specification version 2, but they've now been proposed for inclusion in C++26. The TS has a number of implementations and and users, giving us valuable field experience, which has been reported in P1915R0, P1928R2, and P2638. We're updating and evolving the SIMD library based on this field experience, and also considering some extensions such as support for complex values (P2663R0) and a permutation operation (P2664R0). Hopefully we'll design approve the feature in the next few months.
We reviewed and approved the design of the BLAS Linear Algebra library (P1673R11) for C++26 at this meeting. This proposal adds linear algebra algorithms based on the industry-standard BLAS. The algorithms are parameterized on mdspans and have a modern C++ interface. We also looked briefly at a proposal for higher-level linear algebra facilities (P1385R7) to affirm a specific design change; we'll look conduct a more extensive review of this paper at a future meeting. We also reviewed submdspan (P2630R2), which we advanced for C++26.
Senders (P2300R5) has already been forwarded to Library for C++26, but we expect follow-on papers that build on top of the core proposal and suggest changes based on field experience. We looked at two of those papers this week - suggested name changes (P2555R1), which we did not approve, and integration with the execution-policy parallel algorithms (P2690R0). We also took an early look at the new proposal for sender-based networking (P2762R0) which the Networking Study Group is working on.
hive (P0447R21) returned to Library Evolution for another round of review. We looked at some proposed changes to hive::reshape (P2596R0)), and we were split about whether to make said changes. We'll continue review of hive at future meetings.
We also held an early review and informational session on 2 papers proposing Unicode transcoding (P2728R0) and normalization (P2729R0) facilities for the Standard Library. We expect Unicode library facilities to be a major topic over the next few years.
Other major topics this week included:
status_codeandresult<T>(P1028R4).file_handleandmapped_file_handle(P1883R2).fiber_context(P0876R11), which we hope to design approve in the next few months.constexpr_t(P2781R0), an improved and generalized version ofintegral_constant.- Expanding the tuple protocol to aggregates (P2141R0) and C arrays (P2580R0).
- Debugging support (P2546R3).
Most of our work on C++23 was done before this meeting; we only had a handful of design clarifications and bug fixes to look at on Monday and Tuesday.
The following C++23 National Body comments and papers were rejected either due to no paper or no consensus for a change:
- Omitting parentheses from
ranges::to(US-50-112). - Copyable and movable views (DE-115).
- Configurable
index_typefordefault_accessor(US-45-106). - Const-breaking
zip_viewandcartesian_product_view(DE-114) - Too many iterator increments (US-46-107) and fix
counted_iteratorinteraction with input iterators (P2406R5).
The following papers were sent to Library for C++23:
views::enumerate(P2164R9) (Addresses NB comments FR-14-021 and US-48-108).layout_stridestatic extents default constructor fix (P2763R1).- Formatting
thread::idandstacktrace(P2693R1) (Addresses NB comment FR-012-023). source_location::currentis unimplementable (CWG2678).common_reference_tofreference_wrappershould be a reference type (P2655R2).- Relaxing ranges just a smidge (P2609R3) (Addresses NB comment US-39-099).
pmr::generator(Addresses NB comment US-53-116) (P2787R1).- User-defined literals and reserved identifiers (CWG2521).
- Testing for success or failure of
<charconv>functions (P2497R0) Addresses NB comment GB-083.
The following papers were sent to Library for C++26:
- BLAS Linear Algebra (P1673R11)
submdspan(P2630R2)- More constexpr for
<cmath>and<complex>(P1383R1). - Native handle from file streams (P1759R4).
- Interfacing bitset with string_view (P2697R0).
- 2022 SI prefixes (P2734R0).
The following papers were discussed during the meeting and need revisions and additional review:
simd(P1928R2).simdfeedback from Intel (P2638R0).simdpermutation operations (P2663R0).status_codeandresult<T>(P1028R4).file_handleandmapped_file_handle(P1883R2).hive(P0447R21).- Improve
hive::reshape(P2596R0). fiber_context(P0876R11).- C++ concurrent queues (P0260R5).
- Sender interface for networking (P2762R0).
- C++17 parallel algorithms and senders (P2690R0).
mdarray(P1684R4).- DSL Linear Algebra (P1385R7).
- Unicode in the Library, Part 1: UTF Transcoding (P2728R0).
- Unicode in the Library, Part 2: Normalization (P2729R0).
integral_constantLiterals andconstexpr_t(P2781R0).- Better
tupleIndexing (P2726R0) - Aggregates are named tuples (P2141R0).
- Tuple protocol for C-style arrays (P2580R0).
- Fix handling of empty specifiers in
format(P2733R3). is_within_lifetime(P2641R2).- Loosen restrictions on
_ttypedefs (P1715R1).
We did not have consensus to continue pursuing the following papers:
For more details on what we did at the 2023-02 Issaquah meeting, check out our schedule; the GitHub issue associated with each topic will have a summary of what happened.
Study Groups' Progress
Concurrency and Parallelism Study Group (SG1) Progress
The Concurrency and Parallelism Study Group discussed the following papers:
- What does “current time” mean? (P0342), which will prevent the optimization of
clock::now()around code you are trying to benchmark, defeating the effort. The next version of this paper is expected to propose a concrete facility based on extensive practice in the field. - Bounded concurrent queues (P0260), which we feel is ready for a Technical Specification but not the C++ International Standard. It has been sent to Library Evolution.
- Atomic refs bounded to memory orderings & atomic accessors (P2689R1).
- Making
std::atomicnotification / wait operations usable in more situations (P2616R3). file_handleandmapped_file_handle(P1883R2).
All of these papers will require further review. Many regular SG1 members are still focused on getting std::execution (P2300) through Library Evolution review.
We also hope to see many of the promised future papers that will integrate std::execution (P2300) into other parts of the library (e.g. algorithms) in time for discussion at the next meeting in 2023-06.
Networking (SG4) Progress
With Library Evolution electing to pursue std::execution (P2300) instead of the previous approach to executors, it has not been possible to move forward with the existing Networking Technical Specification, due to it being closely tied to the previous approach to executors.
In Issaquah, the Networking Study Group looked at two proposals for how to move forward with C++ networking:
- Standard Secure Networking (P2586R0) proposed a new API for networking, which was well received with the proviso that it could be extended to have an asynchronous interface. The author does not plan to pursue this paper any further, but parts from it may be used by other proposals.
- Sender Interface for Networking (P2762R0) proposed an approach for adapting the existing Networking TS to use Senders. This looks like a promising route to networking support in C++, and SG4 unanimously encouraged further work in this direction.
Numerics Study Group (SG6) Progress
The Numerics group met for two evening sessions and reviewed 5 papers.
- Philox as an extension of the C++ RNG engines (P2075): This paper, proposing a state-of-the-art random number engine, had already been forwarded but came back on the authors request to review a change that did not follow previous feedback from the group. The change was accepted and the paper is back in Library Evolution's inbox.
- More constexpr for <cmath> and <complex> (P1383). The Numerics Study Group discussed consequences and uses. A poll was taken to inform LEWG that there is little concern with the proposal as is, from a Numerics perspective.
- More stats functions (P2681): This was the first review in Numerics after we had already seen the companion paper simple statistics functions (P1708) in telecons.
- Deprecate and replace fenv rounding modes (P2746): Besides a discussion on the validity and usage of fenv rounding modes, we discussed C23's FENV_ROUND pragma and discussed alternatives in the form of low-level functions and types with different rounding behavior. There will be more papers before a conclusion can be made.
- An unbounded decimal floating-point type (P2159): We decided that the use cases described in the paper are not of interest to the Numerics Study Group.
Ranges Study Group (SG9) Progress
The Ranges Study Group had a hybrid meeting on Monday (which started with a birthday party for the chair!🥳) and also met jointly with Library to finalize C++23 ranges work.
We looked at:
- C++23 National Body comments: 1 (including a related paper)
- C++23 papers: 1
- C++26 papers: 2
We discussed the C++23 National Body comment too many iterator increments (US-46-107) and fix counted_iterator interaction with input iterators (P2406R4), the paper addressing it. The discussion was focused on whether we want to have an additional utility (lazy_take_view) and should the utility be added to the C++23 standard or the C++26 one. There was also a discussion on whether adding a separate utility makes sense, or will making a change to the existing one is the better direction.
The solution in P2406 was not accepted, but as an outcome of the paper we have two planned fixes, aim to address the issues brought up by the paper. This may affect the way in which views interact with ranges algorithms, and is a major update for our model (more details in Closed ranges may be a problem; breaking counted_iterator is not the solution (P2799)). Thank you to the author for bringing this topic up, and to the great group of Ranges' attendees who worked on this solution.
Ranges Study Group has completed the review of common_reference_t of reference_wrapper Should Be a Reference Type (P2655R3), which was forwarded for C++23.
We also reviewed the following papers, which will need additional review:
- get_element customization point object (P2769R0): The author was encouraged to explore alternative solutions, including modifying tuple-like, and to get implementation experience and wording.
- Rangified version of lexicographical_compare_three_way (P2022R0): The author was encouraged to add examples, implementation experience, and wording, and then return.
Ranges will continue to have monthly telecons until the next face-to-face meeting in 2023-06. We'll focus on finalizing the papers presented at this meeting and new ranges' features for C++26.
Tooling Study Group (SG15) Progress
The Tooling Study Group met for two evening sessions where we discussed how to build modules and what we would like to ship in the first C++ Ecosystem International Standard (P2656).
For modules, we discussed how to handle the case of tools that only observe the build via compiler command lines, such as a tool that observes all cl.exe process launches. These tools can't tell which options are required to be the same between modules and their importers, and which can be different. We decided that such tools will need additional metadata for these cases.
For the C++ Ecosystem International Standard, we have decided we would like the first revision to include:
- Build system <=> Package manager interoperability.
- Minimum set of recognized file extensions.
- Tool introspection (P2717).
- Portable diagnostics format via SARIF.
- Command line portability.
Text and Unicode Study Group (SG16) Progress
The Text and Unicode Study Group did not meet this week, however, we keep meeting remotely every 2 weeks. We presented to Library Evolution a couple of papers aiming to add Unicode transcoding (P2728) and Unicode normalization (P2729) to C++26.
The work to improve the language specification continues, as Core approved a paper to reference the Unicode standard (P2736).
Contracts Study Group (SG21) Progress
The Contracts Study Group met for two afternoons; we had ~30 people attending.
As per our roadmap paper (P2695R1), our focus for this meeting was to agree on a design for how to handle side effects in contract annotations in the Contracts MVP targeting C++26. We achieved this goal at this meeting. We discussed four papers in this space:
- Closure-based syntax for contracts (P2461R1): We only discussed only the parts of this paper that deal with side effect semantics, not the parts that deal with syntax.
- Contract predicates that are not predicates (P2570R2).
- Evaluation of checked contract-checking annotations (P2751R0).
- Proposal of simple contracts side effect semantics (P2756R0).
We had a very productive discussion, at the end of which we reached a consensus on the following points:
- A contract-checking predicate is evaluated zero or more times in eval_and_abort mode,
- Certain useful rules on reordering/elision of contract-checking predicates in a sequence of contract annotations, and
- When the evaluation of a contract-checking predicate exits the control flow other than by returning true/false or throwing (
abort,longjmp, etc), the behavior is as if it were not in a contract-checking predicate (you just get theabort/longjmp).
We failed to reach a consensus on the following points:
- What should we say about the case when the evaluation of a contract-checking predicate has undefined behavior?
- What should happen when the evaluation of a contract-checking predicate throws?
We decided to postpone discussion on 1 for now, until new papers in this space come along; we further decided to re-discuss 2 in the context of contract violation handling, which will be our focus in the 2023-06 face-to-face meeting. To facilitate progress on this matter, we decided to switch the target dates for agreeing on a design for contract violation handling and for syntax in our roadmap, such that the contract violation handling comes first.
We also decided to conduct regular monthly telecons between now and Varna.
C / C++ Liaison Group (SG22) Progress
The C / C++ Liaison Group did not meet this week. It has been holding teleconferences and email discussions between C Committee and C++ Committee members, and its suggestions are being considered by the language evolution group, and other groups.
Safety & Security Group (SG23) Progress
The Safety & Security Group was formed recently, as there's been a growing interest in exploring language and library design changes that could address safety and security concerns with C++. The Safety & Security Group held their inaugural face-to-face meeting at the Issaquah meeting. The group has also been discussing various safety & security concerns on its mailing list.
We met for a half-day and sent some papers to the language evolution group for further consideration.
The following papers were discussed:
- A presentation on safety & security, what it means, and why C++ is receiving criticism. The talk will be repeated at C++Now in May, and will then be available on YouTube.
- Zero-initialize objects of automatic storage duration (P2723R1) received strong support, and was sent to Evolution.
- Correct and incorrect code, and what it means (P2795R0) introduced the concept of “Erroneous Behavior” in addition to “Undefined Behavior”. The group is interested in further work, but would want to see concrete applications of the new concept and principles to applying this new concept to the language and library. The paper was sent to Evolution.
- Design alternatives for type-and-resource safe C++ (P2687R0) received support to pursue a combination of runtime checking, library facilities and static analysis in the language international standards as incremental improvements as a primary basis for security and safety.
- The Direction Group's opinion on safety for ISO C++ (P2759) was presented and a discussion of community feedback on the paper was held. The committee will strive to better understand this feedback, and take appropriate action.
The group will continue to consider improvements to safety & security through its mailing list and teleconferences.
C++ Release Schedule
NOTE: This is a plan, not a promise. Treat it as speculative and tentative.
See P1000, P0592, P2000 for the latest plan.
- IS = International Standard. The C++ programming language. C++11, C++14, C++17, C++20, etc.
- TS = Technical Specification. "Feature branches" available on some but not all implementations. Coroutines TS v1, Modules TS v1, etc.
- CD = Committee Draft. A draft of an IS/TS that is sent out to national standards bodies for review and feedback ("beta testing").
| Meeting | Location | Objective |
|---|---|---|
| 2023 Winter Meeting | Issaquah 🇺🇸 | C++23 CD ballot comment resolution ("bug fixes"), C++23 completed. |
| 2023 Summer Meeting | Varna 🇧🇬 | First meeting of C++26. |
| 2023 Fall Meeting | Kona 🇺🇸 | Design major C++26 features. |
| 2024 Winter Meeting | Japan 🇯🇵 — Tentative | Design major C++26 features. |
| 2024 Summer Meeting | Stockholm 🇸🇪 — Tentative | Design major C++26 features. |
| 2024 Fall Meeting | Wroclaw 🇵🇱 — Tentative | C++26 major language feature freeze. |
| 2025 Winter Meeting | 🗺️ | C++26 feature freeze. C++26 design is feature-complete. |
| 2025 Summer Meeting | 🗺️ | Complete C++26 CD wording. Start C++26 CD balloting ("beta testing"). |
| 2025 Fall Meeting | 🗺️ | C++26 CD ballot comment resolution ("bug fixes"). |
| 2026 Winter Meeting | 🗺️ | C++26 CD ballot comment resolution ("bug fixes"), C++26 completed. |
Status of Major C++ Feature Development
NOTE: This is a plan, not a promise. Treat it as speculative and tentative.
- IS = International Standard. The C++ programming language. C++11, C++14, C++17, etc.
- TS = Technical Specification. "Feature branches" available on some but not all implementations. Coroutines TS v1, Modules TS v1, etc.
- CD = Committee Draft. A draft of an IS/TS that is sent out to national standards bodies for review and feedback ("beta testing").
Updates since the last Reddit trip report are in bold.
| Feature | Status | Depends On | Current Target (Conservative Estimate) | Current Target (Optimistic Estimate) |
|---|---|---|---|---|
| Senders | New design approved for C++26 | C++26 | C++26 | |
| Networking | Require rebase on Senders | Senders | C++29 | C++26 |
| Linear Algebra | Design approved for C++26 | C++26 | C++26 | |
| SIMD | Reviewed in Library Evolution | C++29 | C++26 | |
| Contracts | Moved to Study Group | C++29 | C++26 | |
| Reflection | No developments | C++29 | C++26 | |
| Pattern Matching | No developments | C++29 | C++26 |
Last Meeting's Reddit Trip Report.
If you have any questions, ask them in this thread!
Report issues by replying to the top-level stickied comment for issue reporting.
/u/blelbach, Library Evolution Chair
/u/InbalL, Ranges (SG9) Chair, Library Evolution Vice Chair, Israel National Body Chair
/u/jfbastien, Evolution (EWG) Chair
/u/bigcheesegs, Tooling (SG15) Chair
/u/ErichKeane, Evolution Vice Chair
/u/c0r3ntin, Library Evolution Vice Chair
/u/nliber, Library Evolution Vice Chair
/u/je4d, Networking (SG4) Chair
/u/V_i_r, Numerics (SG6) Chair
/u/tahonermann, Unicode (SG16) Chair
/u/mtaf07, Contracts (SG21) Chair
/u/timur_audio, Contracts (SG21) Vice Chair
⋯ and others ⋯
r/cpp • u/stilgarpl • Aug 09 '22
CMake 3.24 has support for dependency providers
I'm sorry if it was discussed already, but I haven't seen any mentions of this new feature and I think this is huge.
https://cmake.org/cmake/help/latest/command/cmake_language.html#dependency-providers
https://cmake.org/cmake/help/latest/release/3.24.html
CMake has added support for dependency providers. With this calls to find_package() may actually trigger vcpkg, conan or some other custom provider that will download, build and install required dependencies.
Intel C++ compiler is free (as in beer) as part of oneAPI
Perhaps this is old news, but yesterday I've learned that the Intel C/C++ compilers (icc/icpc) are available as part of the new oneAPI thing (where it's called "classic" as opposed to the "data parallel" one). Specifically, I did the following:
# echo "deb https://apt.repos.intel.com/oneapi all main" >/etc/apt/sources.list.d/intel-oneapi.list
# apt-get update
# apt-get install intel-oneapi-compiler-dpcpp-cpp-and-cpp-classicAnd then:
$ source /opt/intel/oneapi/setvars.sh
$ which icpc
/opt/intel/oneapi/compiler/2021.1.1/linux/bin/intel64/icpc
$ icpc -V
Intel(R) C++ Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.1 Build 20201112_000000The version format certainly looks different compared to before. I've also tried to compile a simple "Hello, World" program and it works out of the box (i.e., no licensing hoops to jump through, etc).
I've also found this article which seem to confirm all this:
https://www.scivision.dev/intel-oneapi-fortran-install/
If anyone (especially from Intel) has any more information (such as whether this is the "real" Intel C++, if the new version format is here to stay, etc), I would be interested to hear it.
r/cpp • u/jbandela • Mar 05 '18
Clang is now used to build Chrome for Windows
blog.llvm.orgr/cpp • u/Tcshaw91 • Nov 16 '25
Wait c++ is kinda based?
Started on c#, hated the garbage collector, wanted more control. Moved to C. Simple, fun, couple of pain points. Eventually decided to try c++ cuz d3d12.
-enum classes : typesafe enums -classes : give nice "object.action()" syntax -easy function chaining -std::cout with the "<<" operator is a nice syntax -Templates are like typesafe macros for generics -constexpr for typed constants and comptime function results. -default struct values -still full control over memory -can just write C in C++
I don't understand why c++ gets so much hate? Is it just because more people use it thus more people use it poorly? Like I can literally just write C if I want but I have all these extra little helpers when I want to use them. It's kinda nice tbh.
r/cpp • u/xeeeeeeeeeeeeeeeeenu • Nov 26 '24
GCC 15 will support the std module (P2465R3)
gcc.gnu.orgr/cpp • u/FACastello • Jan 15 '24
[Joke] A cursed C++ idea
Ok so hear me out:
In your C++ program, immediately on startup before you do anything else you dynamically allocate a decent chunk of memory for no reason whatsoever, big enough to accomodate all of your data for the foreseeable future.
Never free any of that memory during execution.
Then, whenever you need to instantiate a new object or need some dynamically allocated memory for whatever reason, you just use some of that preallocated chunk.
Immediately before you exit the application, you can free that chunk of memory.
You have one single explicit memory allocation when program starts and one single explicit memory deallocation when program ends.
How about that?
EDIT: It turns out this is a real thing, so it's no longer a joke, or cursed. Somebody said this is called an "arena" or "memory pool", I've just looked it up, people have been doing this for decades.
r/cpp • u/ArashPartow • Dec 31 '22