-
Stay up-to-date with everything C++! Content directly fetched from the subreddit just for you. Join our group for discussions : @programminginc Powered by : @r_channels
C++ Show and Tell - March 2025
Use this thread to share anything you've written in C++. This includes:
* a tool you've written
* a game you've been working on
* your first non-trivial C++ program
The rules of this thread are very straight forward:
* The project must involve C++ in some way.
* It must be something you (alone or with others) have done.
* Please share a link, if applicable.
* Please post images, if applicable.
If you're working on a C++ library, you can also share new releases or major updates in a dedicated post as before. The line we're drawing is between "written in C++" and "useful for C++ programmers specifically". If you're writing a C++ library or tool for C++ developers, that's something C++ programmers can use and is on-topic for a main submission. It's different if you're just using C++ to implement a generic program that isn't specifically about C++: you're free to share it here, but it wouldn't quite fit as a standalone post.
Last month's thread: https://www.reddit.com/r/cpp/comments/1igxv0j/comment/mfe6ox4/?context=3
https://redd.it/1j0xv13
@r_cpp
Why does this slight code change increase memory usage 25 fold?
Hi, I'm unsure if this is the right place to ask, but I was working on a leetcode problem with C++ and noticed something weird: Memory usage increases 25-fold when changing a simple if conditional block. Is there some hidden complexity to using the ternary operator or is leetcode just buggy?
Link: https://godbolt.org/z/x5W8Kn44z
I'm a college student who hasn't worked with C++ outside of college, so I don't know why this is the case.
Thanks for reading
https://redd.it/1j0syhs
@r_cpp
STL Algorithms: More than toy examples
I write a lot of embedded C++ code for manipulating large-ish numerical data sets. I every six months or so, think to myself, "I should be using the STL Algorithms. It would make my code clearer."
The Algorithms look great in CppCon presentations, but I find I never just want to know the min. value in a set, or just find a single value. If a dataset is worth analyzing, then I want the min, average, max, and I want to search for multiple properties (like every inflection point). Suddenly, STL Algorithms become a huge performance hit, because they require the MCU to re-iterate through the entire data set again for each property.
Here is an example: https://godbolt.org/z/zczsEj1G5
The assembly for stats_algo() has 5 jump targets. While stats_raw_loop() has just one!
What am I missing? Can anyone show me a real-world data analysis example where STL Algorithms don't cause a performance hit?
https://redd.it/1j0l3xj
@r_cpp
C++ in the Linux kernel (for safety & features) gaining traction
\[PATCH 00/45\ C++: Convert the kernel to C++](https://lkml.org/lkml/2025/2/27/1547)
I've been randomly scrolling through the Hottest messages of LKML these days and found this very interesting topic.
This is related to a previous post, if you want to check
https://redd.it/1j06i94
@r_cpp
type++: Prohibiting Type Confusion with Inline Type Information
https://www.ndss-symposium.org/ndss-paper/type-prohibiting-type-confusion-with-inline-type-information/
https://redd.it/1j007cu
@r_cpp
$(shell expr $(i) - 1), $(HEADER_UNIT_CMIS))) \
)
$(DEPS): $(HEADER_UNIT_CMIS)
What it does:
1. Take a list of C++ headerfiles, e.g. `A.h B.h C.h`
2. Generate rules, e.g.
A.h.gcm: A.h
$(CXX) -c -fmodule-header $(CPPFLAGS) $(CXXFLAGS) A.h
B.h.gcm: B.h
$(CXX) -c -fmodule-header $(CPPFLAGS) $(CXXFLAGS) B.h
C.h.gcm: C.h
$(CXX) -c -fmodule-header $(CPPFLAGS) $(CXXFLAGS) C.h
3. Fill prerequisites one by one, e.g.
A.h.gcm: B.h.gcm
B.h.gcm: C.h.gcm
4. Do something to ensure header unit CMIs are generated before all other actions.
I know. Bloody horrible. But it works. Though badly. I tried my best. With current facilities.
# Implementation
[Here](https://github.com/vspefs/gcc/tree/module-makefile-gen-fix)'s the GCC repo with my patch and some minor fixes. It's so roughly made that it breaks the [P1689R5](wg21.link/p1689r5)-format deps json generation functionality. By the way, I forked the repo, edited the 3 files in place on GitHub website, which is why there are 3 commits. They should be 1 commit, really.
# Example project
See [here](https://github.com/vspefs/makefile-cxx-module).
# Please don't embarrass me if I'm wrong
I'm super noob and anxious about it. Just tell me quietly and I'll delete this post. T_T
https://redd.it/1izg2cc
@r_cpp
Best GUI framework for a commercial computer vision desktop app? Qt or alternatives?
Hi, I am thinking to build some desktop app and try to sell it maybe at some point. I have some codes with opencv and etc. but need a GUI because it is just better for the industry that we want to focus. I need a really good advice on GUI does buying Qt worth it? or would we be better of with some open source libraries? The thing is we want to show something that looks professional and really nice to customer and do not want to take a chance. Although Qt's Designer and Creator tools can speed up the coding process, my main focus is on achieving a professional and aesthetically pleasing look, rather than reducing development effort. Also cross platform is needed
looking forward for answers and suggestions from professionals.
thanks
https://redd.it/1inltsc
@r_cpp
What You Need to Know when Optimizations Changes the Behavior of Your C++
https://shafik.github.io/c++/undefined%20behavior/llvm/2025/02/11/when-opt-changes-program-behavior.html
https://redd.it/1ini38y
@r_cpp
Diffie Hellman Key Exchange in c++
Diffie Hellman Key Exchange in c++
Its not perfect but listening to my teacher talk about the DHP in class today as a Computer Science major made me want to program something that would simulate the Diffie Hellman Key Exchange.
If you guys have any advice for how I can touch it up let me know! I am kinda using it to learn c++ and learn the DHP at the same time. Advise for either syntax, style, readability, optimization, or even DHP is very welcome!
Thanks!
#include <iostream>
#include <cmath>
using namespace std;
class Agent
{
private:
int littleA, bigA, sharedSecret;
public:
Agent() : littleA(1), bigA(1), sharedSecret(1) {}
void setPrivateSecret(int para3); // a
void calculateAorB(int g, int p);
void setSharedSecret(int bigB, int p);
int getPersonalSecret();
int getSharedSecret();
int getBigA();
};
class DiffieHellmanProblem
{
private:
int p, h, g;
int bigA, bigB;
public:
DiffieHellmanProblem() : p(1), h(1), g(0) {}
void setPublicPrime(int para1); // p
void setPublicBase(int para2); // g
// void setSharedSecret(int para3); // k
int getPublicPrime();
int getPublicBase();
// int getSharedSecret();
void solve(int attempts);
};
// ---
void Agent::setPrivateSecret(int para3)
{
littleA = para3;
}
void Agent::calculateAorB(int g, int p)
{
// Public base (g) ^ Private Secret (a) mod Public Prime (p)
bigA = (static_cast<int>(pow(g, littleA)) % p);
}
int Agent::getBigA()
{
return bigA;
}
void Agent::setSharedSecret(int bigB, int p)
{
sharedSecret = static_cast<int>(pow(bigB, littleA)) % p;
}
int Agent::getPersonalSecret()
{
return littleA;
}
int Agent::getSharedSecret()
{
return sharedSecret;
}
// ---
void DiffieHellmanProblem::setPublicPrime(int para1)
{
p = para1;
}
void DiffieHellmanProblem::setPublicBase(int para2)
{
g = para2;
}
/*
void DiffieHellmanProblem::setSharedSecret(int para3)
{
k = para2;
}
*/
int DiffieHellmanProblem::getPublicPrime()
{
return p;
}
int DiffieHellmanProblem::getPublicBase()
{
return g;
}
/*
int DiffieHellmanProblem::getSharedSecret()
{
return k;
}
*/
void DiffieHellmanProblem::solve(int attempts)
{
int i;
for (i = 0; i < attempts; i++)
{
}
}
// ---
int main()
{
DiffieHellmanProblem test;
Agent alice;
Agent bob;
int p, g, h, a;
// getting Public Prime and Public Base
cout << "\n\n\nType a value for the Public Prime, followed by a space, followed \n";
cout << "by a value for the Public Base.\n>";
cin >> p;
cin >> g;
cout << "Public knowlege: \nPublic Prime: " << p << "\nPublic Base: " << g << endl;
test.setPublicPrime(p);
test.setPublicBase(g);
// getting Private Secret for Alice
cout << "\nType Alice's secret number: ";
cin >> a;
cout << "\nSecret number recorded: " << a << endl << endl;
alice.setPrivateSecret(a);
// getting Private Secret for Bob
cout << "\nType Bob's secret number: ";
cin >> a;
cout << "\nSecret number recorded: " << a << endl << endl;
bob.setPrivateSecret(a);
// calculating Personal Public Variables A and B
alice.calculateAorB(test.getPublicPrime(), test.getPublicBase());
bob.calculateAorB(test.getPublicPrime(), test.getPublicBase());
// printing A Personal Public Variables A and B
// bigA = (static_cast<int>(pow(g, littleA)) % p);
cout << "Alice's Personal Public Variable (Public Base (";
cout <<
Learning CPP
Hi all, i work in sound design and my boss has asked me to work out how to make audio plugins, my own research led me to C++ being the best for this sort of work as the open source program JUCE (for making plugins) uses it. Just wondering if anyone here has experience in that field and what the best steps to learning C++ are.
Thank you for your time
https://redd.it/1inck8q
@r_cpp
Pthreads
When do we need use pthreads exactly?, because there will always be some shared memory which the threads need to use for their task so how do we know where threads would be useful. Thank you
https://redd.it/1in40ks
@r_cpp
Why is std::reverseiterator's operator-> so counterintuitive?
For the last couple of hours I was chasing a very odd "bug" in my code, that now leaves me with more questions than answers, I hope someone can shine some light here.
I have a for loop that is intended to iterate over QJsonArray (Qt framework, but the problem is not Qt specific). That class doesn't have a reverse iterator, so to get that, I've wrapped the QJsonArray::iterator in std::reverse\iterator as follows.
QJsonArray arrdata = /*valid data loaded from a string*/;
for (std::reverseiterator<QJsonArray::iterator> it = std::makereverseiterator(arrdata.end()); it != std::makereverseiterator(arrdata.begin()); ++it) {
bool b1 = it->isObject(); //this doesn't work
bool b2 =(--it.base())->isObject(); //this works fine
}
To my understanding that is the correct way of creating a reverse iterator, by passing a forward iterator to std::make_reverse_iterator. The iteration part works fine, if the array has 4 elements, the loop will iterate 4 times and exit. The problem starts when I try to access the current element.
I tried the "obvious" it->isObject() call. My expectation here is that operator-> will return the underlying element that the iterator is pointing to. But it doesn't. It seems that they returned element is the forward iterator. So as a result it compiles, but throws a segmentation fault (in Linux) and access violation (in Windows). It's consistent between gcc11 and msvc1929. According to cppreference the operator-> should access the underlying element, so I guess it technically does, but what is the point if it's just another iterator? Explicitly calling base() and back iterating by one item does what the operator-> should do. Why is that? What about the standard library am I missing here?
https://redd.it/1imzwp2
@r_cpp
The Fibonacci sequence in one line of code using the properties of the comma operator
std::cout << "0\n1\n1" << std::endl; for (int j = 1, i = 0; j = (i = j - i, j + i); std::cout << j << std::endl) {if (j == 1134903170)break;}
https://redd.it/1imnby9
@r_cpp
16 years ago
Hey,
16 years ago, I started that project that allows you to code sites in C++. I was 15 years old. I actually showed it to Bjarne Stroustrup on Skype and he said “interesting”. I sold this technology to a few companies in the past.
I never released it, but I’ve been working on it ever since. Configuring requests uses mdk, a programming language that I created that is very similar to C++ but with custom features. If you know C++, then you know MDK :).
Examples of sites that use it: james.com, shinepost.com, and a few other sites I own.
If you look at shinepost, you’ll see it’s fully obfuscated (it’s part of the features).
Anyways, I want to release it soon.
The reason of this post is because I wanted advanced users to try it and give me feedback before I release it. Send me a message on reddit and I’ll add you in for testing day shortly.
https://redd.it/1imfsjo
@r_cpp
Why does everyone fail to optimize this?
Basically c? f1() : f2() vs (c? f1 : f2)()
Yes, the former is technically a direct call and the latter is technically an indirect call.
But logically it's the same thing. There are no observable differences, so the as-if should apply.
The latter is also sometimes strongly preferable, e.g. when there are 10 arguments to pass.
Is there any reason why all the major compilers meticulously preserve the indirection?
https://redd.it/1imdffy
@r_cpp
A short Saturday morning post: What is the difference between COBOL and C++ in being declared dead?
https://a4z.gitlab.io/blog/2025/03/01/COBOL-vs-Cpp.html
https://redd.it/1j0x3bo
@r_cpp
Basics of low latency high performance c++.
I am looking for information on basics of low latency high performance computing for applications like financial software.
How to get started?
https://redd.it/1j0or2a
@r_cpp
A simple static file http server I wrote with c++
This is my first C++ project ever coming from a C programming background .Take a look and tell me what you think .
https://github.com/GeorgeKiritsis/Static-File-Http-Server
https://redd.it/1j0js1o
@r_cpp
Errata: Contracts, ODR and optimizations
I published my trip report about the Hagenberg meeting last week: https://www.think-cell.com/en/career/devblog/trip-report-winter-iso-cpp-meeting-in-hagenberg-austria
It was pointed out to me that I was wrong about the potential for dangerous optimizations with contracts and ODR. The relevant part is:
> At this point, an earlier version of this blog post erroneously wrote how the compiler would further be allowed to assume that the postcondition of abs is true when compiling safe.cpp (after all, the program will be terminated otherwise), and thus optimize on that assumption. This could have lead to further elimination of a the 0 <= x check in the precondition for operator, since it would be redundant with the postcondition of abs. This would then lead to security vulnerabilities, when the checked version of abs is replaced at link-time with the unchecked version from fast.cpp.
>
> Luckily, this is not possible, as has been pointed out to me.
>
> The compiler is only allowed to optimize based on the postcondition of abs if it actually inlines either the call or the postcondition check. If it emits a call to the function, it cannot make any assumption about its behavior, as an inline function is a symbol with weak linkage that can be replaced by the linker—precisely what could happen when linking with fast.cpp. As such, it cannot optimize based on the postcondition unless it makes sure that postcondition actually happens in safe.cpp, regardless of the definition of any weak symbols.
https://redd.it/1j04bwu
@r_cpp
Details of std::mdspan from C++23
https://www.cppstories.com/2025/cpp23_mdspan/
https://redd.it/1izp5wm
@r_cpp
fputs (":", fp);
column++;
column = make_write_vec (d->deps, fp, column, colmax);
if (write_make_modules_deps && !d->cmi_name)
{
fputs ("|", fp);
column++;
make_write_vec (d->modules, fp, column, colmax);
}
fputs ("\n", fp);
if (CPP_OPTION (pfile, deps.phony_targets))
for (unsigned i = 1; i < d->deps.size (); i++)
fprintf (fp, "%s:\n", munge (d->deps[i]));
}
if (!write_make_modules_deps || !d->cmi_name)
return;
column = make_write_name (d->cmi_name, fp, 0, colmax);
fputs (":", fp);
column = make_write_vec (d->deps, fp, column, colmax);
column = make_write_vec (d->modules, fp, column, colmax);
fputs ("|", fp);
column++;
make_write_vec (d->targets, fp, column, colmax);
fputs ("\n", fp);
}
And some explanations:
- `mkdeps` class stores the dependencies (prerequisites in Makefile) of a Makefile target.
- `write_make_modules_deps`, `make_write_name ()`, and other things are what you think they are.
- `d->targets` stores the target(s) to be made. There can be only one target if the source of the target is a module interface unit.
- `d->cmi_name` stores the corresponding CMI name, if the source file of the target is a module interface unit. `nullptr` if not.
- `d->deps` includes the regular deps and header unit deps of a target.
- `d->modules` includes the module deps of a target.
*TL;DR* - If user prompts to generate module dependency information, then:
- If an object target is built from a module interface unit, the rules generated are:
target.o: source.cc regular_prereqs header_unit_prereqs| header_unit_prereqs module_prereqs
source_cmi.gcm: source.cc regular_prereqs header_unit_prereqs module_prereqs| target.o
- If an object target is not, the rule generated is:
target.o: source_files regular_prereqs header_unit_prereqs| header_unit_prereqs module_prereqs
- The `header_unit_prereqs` and `module_prereqs` are actual CMI files.
The last piece we need to solve the module problem is an implicit rule:
%.gcm:
$(CXX) -c -fmodule-only $(CPPFLAGS) $(CXXFLAGS) $<
That's how it works:
1. When a object target, **not compiled from** a module interface unit, is to be built, all its regular prerequisites are checked as before, and if any CMI file it needs do not exist, GNU Make will use the implicit rule to generate one.
This alone does not guarantee CMIs are up-to-date.
2. *[same as above]* **compiled from** *[same as above]*
Furthermore, as `target.o` and `source_cmi.gcm` both have `source.cc` as their prerequisites, and `source_cmi.gcm` has an order-only prerequisite that's `target.o`, it is guaranteed that after `target.o` is built, `source_cmi.gcm` will be built.
Then, if any other target has `source_cmi.gcm` as their normal prerequisite, they will be built after `source_cmi.gcm` is built. In this case, only other CMIs whose interface depends on `source_cmi.gcm` will be built.
For example, when a module interface partition unit is updated, its CMI will get rebuilt, then the CMI of the module interface unit, then the CMIs of other modules that `import` this module.
This guarantees CMIs are always up-to-date.
*TL;DR* - CMIs and object files are managed separately, and it ultimately achieves everything we (at least I) want from modules. Sometimes a CMI might be redundantly built. Once.
# The header units
They're something, aren't they?
Well, currently I don't have a perfect solution to them. What I do now is to have a nice (aka bad) little fragment of Makefile script, which is basically:
HEADER_UNITS := Source files, in dependency order
HEADER_UNIT_CMIS := CMI paths. Let's pretend they are "$(HEADER_UNITS).gcm"
$(HEADER_UNIT_CMIS): %.gcm: %
$(CXX) -c -fmodule-header $(CPPFLAGS) $(CXXFLAGS) $<
$(foreach i, $(shell seq 2 $(words $(HEADER_UNIT_CMIS))), \
$(eval $(word $(i), $(HEADER_UNIT_CMIS)): $(word
Visual Studio 17.13 is released.
https://devblogs.microsoft.com/cppblog/whats-new-for-c-developers-in-visual-studio-2022-17-13/
After hundreds of years, the most hard-to-implement feature is here:
We can finally Set Default File Encoding.
P.S. Of course there is a lot more. Many C++ modules related fixes.
https://redd.it/1injf41
@r_cpp
test.getPublicBase() << ") ^ Personal Secret (";
cout << alice.getPersonalSecret() << ") % " << "Public Prime (";
cout << test.getPublicPrime() << ")): " << alice.getBigA() << endl;
// cout << "Bob's Personal Public Variable: " << bob.getBigA() << endl;
// each agent calculating Shared Secret
cout << "Alice sees Bob's Public Variable (" << bob.getBigA() << ")" << endl << endl;
// cout << "Bob sees Alice's Public Variable (" << alice.getBigA() << ")\n";
cout << "Alice calculates their Shared Secret by by taking Bob's Public Secret ";
cout << "(" << bob.getBigA() << ") " << "and raising it to her Personal Secret (";
cout << alice.getPersonalSecret() << "), and take the modulus with p = ";
cout << test.getPublicPrime() << endl << endl;
alice.setSharedSecret(bob.getBigA(), test.getPublicPrime());
cout << "Shared Secret:\n{" << bob.getBigA() << " ^ ";
cout << alice.getPersonalSecret() << " % " << test.getPublicPrime() << "}\n\n";
cout << "This is equivalent to: " << alice.getSharedSecret();
cout << "\n\n\nReady for more?";
cin >> p;
cout << "\n\n\n";
cout << "Bob calculates their Shared Secret by by taking Alice's public secret ";
cout << "(" << alice.getBigA() << ") " << "and raising it to his Personal Secret (";
cout << bob.getPersonalSecret() << "), and take the modulus with p = ";
cout << test.getPublicPrime() << endl << endl;
bob.setSharedSecret(alice.getBigA(), test.getPublicPrime());
cout << "Shared Secret:\n{" << alice.getBigA() << " ^ ";
cout << bob.getPersonalSecret() << " % " << test.getPublicPrime() << "}\n\n";
cout << "This is equivalent to: " << bob.getSharedSecret();
return 0;
}
https://redd.it/1ingpti
@r_cpp
Simple minimalistic command line parser
I want to share a small tool I wrote for parsing command line arguments
https://github.com/tascvh/SimpleCmdParser
SimpleCmdParser is a minimalistic easy to use command line argument parser for modern C++ applications. It supports handling optional and normal variables, setting default values as well as displaying help messages related to the arguments.
Code critique and suggestions are welcome
https://redd.it/1inepsq
@r_cpp
Why does everyone fail to optimize this? (version 2)
Continuation of my previous post.
Apparently either I cannot write clearly enough, or quite a few people cannot read and understand what it was actually about, so let's try again.
https://godbolt.org/z/EK8qq1z6c
The first example is a baseline. It shows a couple of some external non-inlineable functions:
void f1();
void f2();
Let's call them both:
void f3()
{
f1();
f2();
}
The assembly looks reasonable:
f3():
push rax
call f1()@PLT
pop rax
jmp f2()@PLT
Let's call them conditionally:
void f4(int c)
{
if (c)
f1();
else
f2();
}
The assembly also looks reasonable:
f4(int):
test edi, edi
je f2()@PLT
jmp f1()@PLT
Now, let's add some indirection (the second example):
void f3()
{
auto p1 = &f1;
auto p2 = &f2;
p1();
p2();
}
The assembly is identical to the baseline:
f3():
push rax
call f1()@PLT
pop rax
jmp f2()@PLT
I.e. the compiler figured out that p1 and p2 cannot point to anything but f1 and f2 and removed the indirection. Good job.
Now, let's do it conditionally:
void f4(int c)
{
auto p = c? &f1 : &f2;
p();
}
In this case p also cannot point to anything but f1 or f2, so we can expect a similar optimization, right?
f4(int):
test edi, edi
jne .LBB11
mov rax, qword ptr [rip + f2()@GOTPCREL]
jmp rax
.LBB11:
mov rax, qword ptr rip + f1()@GOTPCREL
jmp rax
Notice that there's a branch and then on both paths it puts the function address into rax and then immediately jumps to rax.
This rax detour is not observable by any means and can be replaced with a direct jump under the "as-if" rule.
In other words, it looks like a missing optimization opportunity.
Checking GCC and MSVC behavior is left as an exercise to the reader.
"But why use function pointers in the first place?" is out of scope of this discussion.
https://redd.it/1in9wf8
@r_cpp
Latest News From Upcoming C++ Conferences (2025-02-11)
This Reddit post will now be a roundup of any new news from upcoming conferences with then the full list being available at https://programmingarchive.com/upcoming-conference-news/
If you have looked at the list before and are just looking for any new updates, then you can find them below:
C++Online - 25th - 28th February 2025
Registration Now Open \- Purchase online main conference tickets from £99 (£20 for students) and online workshops for £349 (£90 for students) at https://cpponline.uk/registration/
FREE registrations to anyone who attended C++ on Sea 2024 and anyone who registered for a C++Now ticket AFTER February 27th 2024.
Call For Volunteers Now Closed \- The call for volunteers is now closed.
Call For Online Posters Extended: The call for online posters has been extended to February 14th. Find out more at [https://cpponline.uk/posters](https://cpponline.uk/posters)
Meetups \- If you run a meetup, then host one of your meetups at C++Online which also includes discounted entry for other members of your meetup. Find out more and apply at https://cpponline.uk/call-for-meetups/
ACCU
Online Volunteer Applications Open \- Attend ACCU 2025 online for free by becoming an online volunteer! Find out more and apply! https://docs.google.com/forms/d/e/1FAIpQLSdAG2OQ78UU2GO6ruDqsSqJ3jLtRILzrRc1pD-YZdZNRIxDUQ/viewform?usp=sf\_link
C++Now
Call For Student Volunteers Now Open \- The call for student volunteers is now open! Find out more at https://cppnow.org/announcements/2025/02/accepting-student-volunteer-applications-for-2025/. All applications must be made by Sunday 2nd March
C++Now Call For Speakers Extended \- Speakers now have until 21st February to submit proposals for the C++Now 2025 conference. Find out more at [https://cppnow.org/announcements/2025/01/2025-cfs/](https://cppnow.org/announcements/2025/01/2025-cfs/)
C++OnSea
C++OnSea Call For Speakers Closing Soon \- Speakers have until 21st February to submit proposals for the C++ on Sea 2025 conference. Find out more at [https://cpponsea.uk/callforspeakers](https://cpponsea.uk/callforspeakers)
CppNorth
CppNorth Call For Speakers Closing Soon \- Speakers have until 23rd February to submit proposals for the CppNorth 2025 conference. Find out more at [https://cppnorth.ca/cfp.html](https://cppnorth.ca/cfp.html)
CppCon
CppCon EA 75% Off - Now $37.5 \- This gives you early and exclusive access to the majority of the remaining 2024 sessions and lightning talks for a minimum of 30 days before being publicly released on YouTube. Find out more and purchase at [https://cppcon.org/early-access/](https://cppcon.org/early-access/)
Call For Academy Classes Closed \- The call for CppCon academy classes has now closed.
Core C++
Core C++ 2024 YouTube Videos \- The conference videos for Core C++ 2024 have started going out on YouTube! Subscribe to their YouTube channel to stay up to date as and when new videos are released! corecpp">corecpp" rel="nofollow">https://www.youtube.com/@corecpp
Finally anyone who is coming to a conference in the UK such as ACCU or C++ on Sea from overseas may now be required to obtain Visas to attend. Find out more including how to get a VISA at https://homeofficemedia.blog.gov.uk/electronic-travel-authorisation-eta-factsheet-january-2025/
https://redd.it/1in3907
@r_cpp
What is faster – C++ or Node.js web server (Apache Benchmark)?
C++ web server is 5.4x faster:
C++: 20.5K rps
Node: 3.8K rps
Test: 10000 requests, no concurrency, iMac M3 (Apple Silicon).
Source code: https://github.com/spanarin/node-vs-c-plus-plus
https://redd.it/1imupi6
@r_cpp
Positional named parameters in C++
Unlike Python, C++ doesn’t allow you to pass named positional arguments (yet!). For example, let’s say you have a function that takes 6 parameters, and the last 5 parameters have default values. If you want to change the sixth parameter’s value, you must also write the 4 parameters before it. To me that’s a major inconvenience. It would also be very confusing to a code reviewer as to what value goes with what parameter. Also, there is room for typing mistakes. But there is a solution for it. You can put the default parameters inside a struct and pass it as the single last parameter. See the code snippet below:
// Supposed you have this function
//
void myfunc(int param1,
double param2 = 3.4,
std::string param3 = "CoxBox",
double param4 = 18.0,
long param5 = 10000);
// You want to change param5 to 1000. You must call:
//
myfunc(5, 3.4, "CoxBox", 18.0, 1000);
//
// Instead you can do this
//
struct MyFuncParams {
double param2 { 3.4 };
std::string param3 { "CoxBox" };
double param4 { 18.0 };
long param5 { 10000 };
};
void myfunc(int param1, const MyFuncParams params);
// And call it like this
//
myfunc(5, { .param5 = 1000 });
https://redd.it/1iml4ys
@r_cpp
The "DIVIDULO" operator - The operator combining division and remainder into one!
In C++, we can operator on integers with division and remainder operations. We can say c = a/b or c=a%b. We can't really say that Q,R = A/B with R, until now.
The dividulo operator! The often derided comma operator can be used as the dividulo operator. In its natural C++ form QR=A,B. Division is Q=A/B. Remainder is R=A%B.
Class 'Number' which holds and manages a signed integer can have its operators leveraged so that the oft-unused comma operator can be used for something useful and meaningful.
Behold the invocation
Number operator / (const Number& rhs) const // Integer division
{
return (operator , (rhs)).first;
}
Number operator % (const Number& rhs) const // Integer remainder
{
return (operator , (rhs)).second;
}
std::pair<Number, Number> operator , (const Number& rhs) const // Both division and remainder
{
return std::pair<Number, Number>(1,0);
}
https://redd.it/1imc6qm
@r_cpp
New C++ Conference Videos Released This Month - February 2025 (Updated to include videos released 2025-02-03 - 2025-02-09)
CppCon
2025-02-03 - 2025-02-09
SuperCharge Your Intra-Process Communication Programs With C++20 and Contract-Concept-Implementation Pattern - Arian Ajdari - [https://youtu.be/LpOYabhTEDs](https://youtu.be/LpOYabhTEDs)
C++ 20 Innovations: High-Performance Cross-Platform Architecture in C++ - Noah Stein - https://youtu.be/8MEsM\_YKA3M
Blazing Trails: Building the World's Fastest GameBoy Emulator in Modern C++ - Tom Tesch - [https://youtu.be/4lliFwe5\_yg](https://youtu.be/4lliFwe5_yg)
Implementing Particle Filters with C++ Ranges - Nahuel Espinosa - https://youtu.be/WT-aBT3XulU
Making Hard C++ Tests Easy: A Case Study From the Motion Planning Domain - Chip Hogg - [https://youtu.be/8D7vpR9WCtw](https://youtu.be/8D7vpR9WCtw)
2025-02-27 - 2025-02-02
Refactoring C++ Code for Unit testing with Dependency Injection - Peter Muldoon - https://youtu.be/as5Z45G59Ws
C++ Under the Hood: Internal Class Mechanisms - Chris Ryan - [https://youtu.be/gWinNE5rd6Q](https://youtu.be/gWinNE5rd6Q)
Secrets of C++ Scripting Bindings: Bridging Compile Time and Run Time - Jason Turner - https://youtu.be/Ny9-516Gh28
Building Safe and Reliable Surgical Robotics with C++ - Milad Khaledyan - [https://youtu.be/Lnr75tbeYyA](https://youtu.be/Lnr75tbeYyA)
ISO C++ Standards Committee Panel Discussion 2024 - Hosted by Herb Sutter -https://youtu.be/GDpbM90KKbg
Audio Developer Conference
2025-02-03 - 2025-02-09
Javascript, WebViews and C++ - “If You Can’t Beat Them, Join Them” - Julian Storer - [https://youtu.be/NBRO7EdZ4g0](https://youtu.be/NBRO7EdZ4g0)
How to Build a Simple, Modern & Collaborative DAW for Producers of All Levels - Anurag Choudhary - https://youtu.be/W5v6IZ4Cgjk
Inside Game Audio Programming: Purpose, Process, and Impact - Harleen Singh - [https://youtu.be/iQ7ChqmO0Bs](https://youtu.be/iQ7ChqmO0Bs)
2025-01-27 - 2025-02-02
Keynote: Foundation Models Don’t Understand Me - Lessons From AI Lutherie for Live Performances - Manaswi Mishra - https://youtu.be/SnbJpvz86SM
Shrink Your Virtual Analog Model Neural Networks! - Christopher Clarke - [https://youtu.be/lZxfv0euB98](https://youtu.be/lZxfv0euB98)
In Praise of Loudness - Samuel Fischmann - https://youtu.be/0Hj7PYid\_tE
Core C++
2025-02-03 - 2025-02-09
Debug C++ Programs You did not write - Elazar Leibovich - [https://www.youtube.com/watch?v=RmhvZxwIKEw](https://www.youtube.com/watch?v=RmhvZxwIKEw)
Welcome to the meta::[[verse\]\]! - Inbal Levi - https://www.youtube.com/watch?v=1en5wSqkquQ
2025-01-27 - 2025-02-02
C++ Fundamentals: Unit Testing - Amir Kirsh - [https://www.youtube.com/watch?v=hzQxHrNT-Jw](https://www.youtube.com/watch?v=hzQxHrNT-Jw)
Optimizing Embedded Software Infrastructure - Alex Kushnir, Akram Zoabi - https://www.youtube.com/watch?v=1Lc3R2U87Ak
3D logs to analyze self-driving cars - Ruslan Burakov - [https://www.youtube.com/watch?v=LTZubbUcpnE](https://www.youtube.com/watch?v=LTZubbUcpnE)
Back to Basics: Design Patterns - Noam Weiss - https://www.youtube.com/watch?v=qeU7v1XPBHQ
The Pains and Joys of C++ In-Process Graph Execution - Svyatoslav Feldsherov - [https://www.youtube.com/watch?v=BAylU9BeY4Y](https://www.youtube.com/watch?v=BAylU9BeY4Y)
C++ Fundamentals: Object-Oriented Programming with C++ - Nathanel Green - https://www.youtube.com/watch?v=mD--ExuQXDc
https://redd.it/1im9rws
@r_cpp