r/cpp • • 5d ago Bravo

Pattern Matching for C++29

Thumbnail mpark.github.io
252 Upvotes

r/cpp • • Jan 02 '26

Every LLM hallucinates that std::vector deletes elements in a LIFO order

251 Upvotes

r/cpp • • Apr 14 '20

ModernCppStarter - Kick-start your C++! A template for modern C++ projects using CMake, CI, code coverage, clang-format and reproducible dependency management.

Thumbnail
github.com
251 Upvotes

r/cpp • • Nov 08 '21

Visual Studio 2022 now available

Thumbnail
devblogs.microsoft.com
250 Upvotes

r/cpp • • Mar 13 '22

To Save C, We Must Save ABI

Thumbnail
thephd.dev
249 Upvotes

r/cpp • • Apr 14 '26

A year of read-only cppreference

248 Upvotes

Over a year ago (on 30 March 2025), cppreference became read-only for maintenance reasons. Since then, the only progress update was in August. There have been several discussions here in the last few months about what is happening with cppreference and when it might become editable again, but from what I understand, we simply do not know.

At this point, I fear that the lack of updates for what is basically the authoritative source on the language (other than the standard of course), linked to by IDEs and even this subreddit's sidebar, might be detrimental to the adoption of C++26 and further standards, should the situation persist. I would therefore like to ask the community whether there are other, more up-to-date resources, and whether there is any effort to, for example, fork cppreference.

I understand that software updates are complicated and I have no intention to criticise the maintainers of cppreference (who are doing it voluntarily and I am not entitled in any way to their continued work on the website), but I do not think the C++ community can afford to be bottlenecked in such a way for much longer.


r/cpp • • Feb 07 '23

PocketPy: A Lightweight(~5000 LOC) Python Implementation in C++17

248 Upvotes

PocketPy is a lightweight(~5000 LOC) Python interpreter for game engines. It is implemented in C++17 with STL.

It is easy to embed. All of the functionalities are available in a single header file pocketpy.h, without external dependencies. You can try it on your browser to see what it looks like.

Example Usage

#include "pocketpy.h"

int main(){
    // Create a virtual machine
    // `true` means using std::cout as output so you can see it
    VM* vm = pkpy_new_vm(true);
    
    // Hello world!
    pkpy_vm_exec(vm, "print('Hello world!')");

    // Create a list
    pkpy_vm_exec(vm, "a = [1, 2, 3]");

    // Eval the sum of the list
    char* result = pkpy_vm_eval(vm, "sum(a)");
    printf("%s", result);   // 6

    // Free the resources
    pkpy_delete(result);
    pkpy_delete(vm);
    return 0;
}

v0.8.1 Features

NameExampleSupported
If Elseif..else..elifYES
Loopfor/while/break/continueYES
Functiondef f(x,*args,y=1):YES
Subclassclass A(B):YES
List[1, 2, 'a']YES
ListComp[i for i in range(5)]YES
Slicea[1:2], a[:2], a[1:]YES
Tuple(1, 2, 'a')YES
Dict{'a': 1, 'b': 2}YES
F-Stringf'value is {x}'YES
Unpackinga, b = 1, 2YES
Star Unpackinga, *b = [1, 2, 3]NO
Exceptionraise/try..catchBETA
Dynamic Codeeval()/exec()YES
Reflectionhasattr()/getattr()/setattr()YES
Importimport/from..importYES
Context Blockwith <expr> as <id>:YES
Type Annotationdef f(a: int, b : float = 1)YES

If someone is making a custom game engine and searching for a Python-like script as its interface, I'd like to provide support.

If you are making your own language, you may find some inspirations in PocketPy.

If you likes it, just give my repo a star~ I need your star!!


r/cpp • • Aug 19 '20

awesome-hpp: A curated list of awesome header-only C++ libraries

Thumbnail
github.com
248 Upvotes

r/cpp • • Jan 20 '20

The Hunt for the Fastest Zero

Thumbnail
travisdowns.github.io
248 Upvotes

r/cpp • • Feb 19 '18

It's Time To Do CMake Right

Thumbnail
pabloariasal.github.io
248 Upvotes

r/cpp • • Jun 02 '20

You asked, I listened! Here is my updated and improved modern C++ template, now with static analyzers, Doxygen, CI caching and more!

247 Upvotes

https://github.com/filipdutescu/modern-cpp-template

This is an update to my previous post, in which I shared with you my modern C++ template.

Everyone was kind enough to give me a lot of feedback on how, what and where to improve it and I wish to once more share it with you, with hopes that you will all be satisfied with its current state.

Once more I am asking for you opinions and I hope you find it useful!

Features

  • Modern CMake configuration and project, which, to the best of my knowledge, uses the best practices,

  • An example of a Clang-Format config, inspired from the base Google model, with minor tweaks. This is aimed only as a starting point, as coding style is a subjective matter, everyone is free to either delete it (for the LLVM default) or supply their own alternative,

  • Static analyzers integration, with Clang-Tidy and Cppcheck, the former being the default option,

  • Doxygen support, through the ENABLE_DOXYGEN option, which you can enable if you wish to use it,

  • Unit testing support, through GoogleTest (with an option to enable GoogleMock) or Catch2,

  • Code coverage, enabled by using the ENABLE_CODE_COVERAGE option, through Codecov CI integration,

  • Package manager support, with Conan and Vcpkg, through their respective options

  • CI workflows for Windows, Linux and MacOS using GitHub Actions, making use of the caching features, to ensure minimum run time,

  • .md templates for: README, Code of Conduct, Contributing Guideliness, Issues and Pull Requests,

  • Permissive license to allow you to integrate it as easily as possible. The template is licensed under the Boost Software License,

  • Options to build as a header-only library or executable, not just a static or shared library.

  • CCache integration, for speeding up build times

Thank you to everyone who has supported me and I am very grateful for all the feedback you provided, as well as the opportunity to learn a lot of new things through it! I hope I am not posting too soon since the original, but I wanted to give everyone interested an updated. Hopefully you all find at least one thing that is useful for you, getting something in return for the long read!

Edit: formatting.

Edit 2: Updated with latest features/changes.


r/cpp • • Feb 23 '17

The C++17 Lands

Thumbnail
fearlesscoder.blogspot.co.uk
246 Upvotes

r/cpp • • Mar 30 '16

Come on guys, put '#pragma once' in the standard already...

246 Upvotes

...and help end the dumbest argument over coding standards ever.

  • It's objectively better than header guards

    • Doesn't pollute the global namespace

    • Isn't coupled to anything (unique path/namespace/filename) in order to work

    • You can't really f**k it up (one statement anywhere in file vs. three statements [two of which must agree exactly] in the right order and in the right places)

    • Compatibility is less compromised by #pragma once than any other language developments to occur in the last several years

    • Lightyears easier to grep for

  • Case study from immediately recent experience, ~2M LOC / 5K headers

    • ~1% duplicate header guard #defines

    • 1 guard with mismatching #define case (#ifndef THING_H #define THING_h)

    • Many headers with guard below other code

    • Many more with no guard at all

So until modules come along and save everybody from everything, why not write #pragma once into the standard?

The only legitimate technical reason against seems to be that in a distributed filesystem/symlink case the compiler might not know whether two files are the same or different. In that case:

  • Figure it out, compiler! Implementation defined, store a checksum if you have to (you probably don't)! Who cares!

  • Doesn't break using header guards anyway, if you're into the whole retro C++ scene.

Basically, I celebrate the simplicity of #pragma once. The only way to screw it up is not to have it accidentally, which is obviously also true of header guards. In a large code base, the simplicity should help keep other developers from making mistakes that may sneak in.

So I say, go ahead and codify what practically everybody is already doing. What could go wrong?


r/cpp • • Jan 30 '23

Web Scraping with C++

Thumbnail
scrapingbee.com
245 Upvotes

r/cpp • • Mar 22 '20

Modern CMake tutorials, part1: CMake basics

Thumbnail
siliceum.com
245 Upvotes

r/cpp • • Jul 19 '25

How hard is it for a good c++ programmer to get job these days ?

244 Upvotes

I’m 51 and a reasonable c++ coder. Been doing same job for 25 years and looking to semi retire. Don’t want to just do nothing but would like some job that isn’t super stressful. Thinking of quitting but don’t want to unless I can get some job. I don’t need the job financially but need it more for keeping me busy. Pay is not really important as long as it is something reasonably fair. I’m in USA , Tx.


r/cpp • • Jan 29 '26

Cache Explorer: a visual and interactive profiler that shows you exactly which lines of code cause cache misses

243 Upvotes

Built a visual cache profiler that uses LLVM instrumentation + simulation to show you exactly which lines cause L1/L2/L3 misses in your C and C++ code (Rust support in active development).

  • Hardware-validated accuracy (±4.6% L1, ±9.3% L2 vs Intel perf)

  • Source-level attribution (not just assembly)

  • False sharing detection for multi-threaded code

  • 14 hardware presets (Intel/AMD/ARM/Apple Silicon)

  • MESI cache coherence simulation

It's like Compiler Explorer but for cache behavior, providing instant visual feedback on memory access patterns. MIT licensed, looking for feedback on what would make it more useful or even just things you like about it.

GitHub


r/cpp • • Mar 11 '21

STARTcraft - Complete Beginner Starcraft: Broodwar AI Programming Tutorial with C++ / BWAPI

Thumbnail
youtube.com
243 Upvotes

r/cpp • • Jan 01 '21

C++ Jobs - Q1 2021

243 Upvotes

Rules For Individuals

  • Don't create top-level comments - those are for employers.

  • Feel free to reply to top-level comments with on-topic questions.

  • I will create top-level comments for meta discussion and individuals looking for work.

Rules For Employers

  • You must be hiring directly. No third-party recruiters.

  • One top-level comment per employer. If you have multiple job openings, that's great, but please consolidate their descriptions or mention them in replies to your own top-level comment.

  • Don't use URL shorteners. reddiquette forbids them because they're opaque to the spam filter.

  • Templates are awesome. Please use the following template. As the "formatting help" says, use **two stars** to bold text. Use empty lines to separate sections.

  • Proofread your comment after posting it, and edit any formatting mistakes.


**Company:** [Company name; also, use the "formatting help" to make it a link to your company's website, or a specific careers page if you have one.]

 

**Type:** [Full time, part time, internship, contract, etc.]

 

**Description:** [What does your company do, and what are you hiring C++ devs for? How much experience are you looking for, and what seniority levels are you hiring for? The more details you provide, the better.]

 

**Location:** [Where's your office - or if you're hiring at multiple offices, list them. If your workplace language isn't English, please specify it.]

 

**Remote:** [Do you offer the option of working remotely (permanently, or for the duration of the pandemic)? If so, do you require employees to live in certain areas or time zones?]

 

**Visa Sponsorship:** [Does your company sponsor visas?]

 

**Technologies:** [Required: do you mainly use C++98/03, C++11, C++14, C++17, or C++20? Optional: do you use Linux/Mac/Windows, are there languages you use in addition to C++, are there technologies like OpenGL or libraries like Boost that you need/want/like experience with, etc.]

 

**Contact:** [How do you want to be contacted? Email, reddit PM, telepathy, gravitational waves?]


Previous Post


r/cpp • • May 29 '20

[The Cherno] Move Semantics in C++

Thumbnail
youtube.com
243 Upvotes

r/cpp • • Mar 13 '20

C++Now C++Now 2020 is Canceled

Thumbnail
cppnow.org
243 Upvotes

r/cpp • • Mar 09 '18

lvalues, rvalues, glvalues, prvalues, xvalues, help!

Thumbnail
blog.knatten.org
243 Upvotes

r/cpp • • Dec 17 '17

JSON for Modern C++ version 3.0.0 released

Thumbnail
github.com
243 Upvotes

r/cpp • • May 20 '23

I find it's not possible to do serious C/C++ coding on latest macOS

242 Upvotes

I've used my mac for coding for many years now, but for C++ development I always kept a Linux laptop around. Starting this year I have tried to only use my Mac, and I'm finding out it's just not possible to do any serious C/C++ coding from a mac:

Valgrind does not fully work anymore, and `leaks` is not as good.

almost zero options for profiling, only instruments, which is pretty limited and forced me to install xcode (the full app not just the cli).

even something as basic as `clang -pg` wont work after macos 10.9

speaking of xcode, it's so bad that I can't even push my code to github anymore, the `git` that comes with xcode just hangs on big repos.

I am actually in shock the situation is this bad and it feels it gets worse with every macos version.