#CPP
Related exercise from my C++ intro course asking students to implement isdigit(char) when characters are encoded in a fictional SASSY scheme.
Obvious to many here, this exercise is designed to help students realize that character encodings for digits, etc. don't have to be contiguous (unlike in ASCII).
PS: Students were asked to assign random codes to digit chars not in the table.
[Tweet redux, but reworded for this conversation]

Hoopla just completed Day 4 of #adventofcode2023. The hoops I had to jump through to get part 2 to work for loops in C++ is 😵 But here it is! https://github.com/somecho/aoc23.cpp/blob/main/src/day_4_2.cpp
#cpp #aoc #adventofcode #codingchallenge #functionalprogramming
CLion Nova: A New Update With Various Bug Fixes
#Clang #CLion #News #Releases #Cpp #Clionnova #Codeanalysis #Refactoring #Syntaxstyle
https://blog.jetbrains.com/clion/2023/11/clion-nova-a-new-update-with-various-bug-fixes/
CLion Nova Explodes onto the C and C++ Development Scene
#Clang #CLion #News #Releases #Cpp #Clionnova #Performance
The behavior of std::optional<T>::operator<= is surprising when the first argument is std::nullopt and second argument is a T. It returns true! In my opinion, all comparisons between std::nullopt and T should return false. Someone reported my assumption making one of my supposed NFC patches to #LLVM cause huge regressions on their benchmarks. #cpp
Which of these two versions of the C++ function `isdigit(char)` would you recommend? Why, under what circumstances? 🤔 🧐
Assume architecture-agnostic programs but make (and state) reasonable assumptions.
Compare -O0 and -O3 in GCC and clang for x86-64 on Linux: https://sigcpp.godbolt.org/z/67734GbWP
💭 🔃 🙏
#cpp #cplusplus #programming #question #softwareEngineering #education #learning

📆 Day 4 of Advent of Code 2023 is here. Today, we are analyzing the winning numbers on scratchcards.
🤔 How did you find today's problem? Was it easier for you than Day 3?
#cpp #cplusplus #coding #programming #dailybiteofcpp #adventofcode
One sad reality of helpers like these is that while an optimized build will generate identical code as a regular for loop in this case, an non-optimized build will have function calls to operators instead of a simple increment.
C & C++ recap for week 48/2023
https://discu.eu/weekly/candcpp/2023/48/
#cpp #cprogramming #programming
Get RSS feeds and support this bot with the premium plan: https://discu.eu/premium
The #cpp 'runner' is here https://github.com/mattjbones/advent-of-code/blob/main/2023-cpp/src/runner.cpp / https://github.com/mattjbones/advent-of-code/blob/main/2023-cpp/src/runner.hpp
The #rust 'runner' is here https://github.com/mattjbones/advent-of-code/blob/main/2022-rusty/src/runner.rs
In the rust impl I separated the sample / input functions whereas in c++ I overloaded the `run_input_part_1` with a path or path and expected value.
For now the C++ isn't generic as most of the questions have only required numbers but I can see this moving to a `.tcc` file and be made generic.
I'm bringing you the second quick update for the template repository for Advent of Code.
If you bump the version of the docker image to 20231203 (in .devcontainer), you will get pretty-printing for GDB.
This also applies to the VSCode UI, so VSCode will no longer show the internals of data structures.
I have also added a short section about debugging to the original article:
#cpp #cplusplus #coding #programming #dailybiteofcpp #adventofcode
D Programming Language
Discussions: https://discu.eu/q/https://dlang.org
I just found a piece of old code where I encoded some information into an 8-bit bitfield just to decode it again 3 lines later.
I am certainly wiser now.
C++ standard lib doesn't have any mechanism for range based for loops over just plain numbers, right? Something like python's range. Could look like:
for(int i : range(10)) ...
I know it's trivial to create, I'm just wondering if it's in there somewhere and I've missed it. It's happened before.
In November's newsletter, we bring you new videos as well as two new blogs, a new whitepaper, a manual for KDDockWidgets, a video interview: Why Rust?, two releases: CXX-Qt 0.6 & Slint 1.3, and some great news on KDAB Training. #QtDev #cpp #rustlang
🔗 https://www.kdab.com/https-www-kdab-com-2023-november-newsletter/

I've completed "Scratchcards" - Day 4 - Advent of Code 2023 #AdventOfCode https://adventofcode.com/2023/day/4
#aoc2023 #cpp #AdventOfCode2023 #aoc23_cpp
I don't do Advent of Code, but browsing a few #cpp solutions to Day 1, Part 1, I fear I misunderstand the problem, or I just don't know enough C++. I'm not sure why the solution requires vectors, ranges, algorithms, etc. when it can be done in a single pass over the input stream.
Maybe others' solutions are that way due to Part 2? Na, more likely I'm doing something wrong. 😨
#Spoiler: Images reveal (uncommented) solution


Titus Winters on LinkedIn: As of today, I'm no longer a Googler.
📆 Day 3 of Advent of Code 2023 is here. Today, we are decoding an engine schematic.
😊 Part two today was perhaps the first interesting problem, so how did you do?
💡 Share your solutions.
#cpp #cplusplus #coding #programming #dailybiteofcpp #adventofcode
Started Day three but decided I'd figure out type generics in #cpp for my many `print_line` functions..
Enter `Templates` and after a bit of trial and error I now have `logging.tcc` which contains a bunch of sensible templated functions.
https://github.com/mattjbones/advent-of-code/commit/fe8ab137a48f667a11aa3d614d8442623421e38b
Talking with the inventor of C++ [video]
https://www.youtube.com/watch?v=5uA1-J_Wl4E
Discussions: https://discu.eu/q/https://www.youtube.com/watch?v=5uA1-J_Wl4E
I got roasted by Prime (Youtuber) - and lived to love it. Why C++ is better than Rust.
https://www.youtube.com/watch?v=Wz0H8HFkI9U
Discussions: https://discu.eu/q/https://www.youtube.com/watch?v=Wz0H8HFkI9U
'Pure magical thinking': Albertans filled premier's inbox with emails opposing provincial pension plan
https://libranet.de/display/0b6b25a8-1965-6b98-da37-bd2380135967

Understanding Objective-C by transpiling it to C++
https://www.jviotti.com/2023/12/01/understanding-objective-c-by-transpiling-it-to-cpp.html
Discussions: https://discu.eu/q/https://www.jviotti.com/2023/12/01/understanding-objective-c-by-transpiling-it-to-cpp.html


📆 Day 2 of Advent of Code 2023 is here. Today, we are parsing information about cubes.
😱 Did you struggle with the parsing?
😉 What was your approach?
#cpp #cplusplus #coding #programming #dailybiteofcpp #adventofcode
c++ solution of part 2 of today's #adventofcode WITHOUT for loops: https://github.com/somecho/aoc23.cpp/blob/main/src/day_2_2.cpp
Today's solving of #adventofcode in C++ is mostly me implementing my own utility functions liketrim
(why does C++ not have this) andindexOf
, and just generally figuring out how std::map
(I still haven't really figured it out) and iterators work.
where is the simple `.split(delimiter)` for strings in #cpp
// Initialize the result vector R
for (size_t i = 0; i < m; i++) {
h_R[m] = 0;
}
8 hours of my life threw away because I was too lazy to configure the debugger.
Small Std::format test
https://quick-bench.com/q/8jpwWH0rn4P927hSKVt59AfI_Uk
Discussions: https://discu.eu/q/https://quick-bench.com/q/8jpwWH0rn4P927hSKVt59AfI_Uk
Just a quick update for the AOC template repository.
I only now noticed that the debugger used by the CMake extension was not configured correctly. Right-click on a binary in the CMake panel, and selecting debug will now work correctly.
Either update or change your configuration to:
https://github.com/HappyCerberus/aoc-2023-cpp/commit/e79aa276a6ad1856820fa2cd7bb0a4230de05b13
wow, you sure have to do a lot of the heavy lifting with #cpp includes?
Today I'm tryig to add a bit of structure to my #AdventOfCode and I'm learning all about guarding `#include` .. fun!
Oh also I implemented the minimap. Still a lot of debug text everywhere and placeholder objects, but building out the systems before deciding what exactly I'm going to do with the game.

C++23: Growing unicode support
https://www.sandordargo.com/blog/2023/11/29/cpp23-unicode-support
Discussions: https://discu.eu/q/https://www.sandordargo.com/blog/2023/11/29/cpp23-unicode-support
📆 Day 1 of Advent of Code 2023 is here. Today, we are extracting digits from text.
🥰 Let me know how you managed today.
🔥 Did you take the time to implement a proper optimal solution for part two? 🔥
#cpp #cplusplus #coding #programming #dailybiteofcpp #adventofcode
This year, I'm doing Advent of Code for the second time. Last year I did it (half way) while learning Rust. This year, I'm doing it in C++ with a functional style! I'll be sharing my solutions to this repo: https://github.com/somecho/aoc23.cpp
Compiler Options Hardening Guide for C and C++
Ok, here we go, ready for #AdventOfCode with #CPP characteristics... https://github.com/mattjbones/advent-of-code/blob/main/2023-cpp/src/main.cpp
Also displaying my incomplete #Rust attempt from last year and even the #TypeScript escape hatch
Ok so.. #cpp package manager or build tools, what's the Cargo of the C++ world?
I'm gonna try #poac as it seems pretty nice: https://github.com/poac-dev/poac though the builds failling on GitHub aren't encouraging.
MISRA C++:2023 (Guidelines for the use C++:17 in critical systems) published
https://forum.misra.org.uk/thread-1668.html
Discussions: https://discu.eu/q/https://forum.misra.org.uk/thread-1668.html
⚡ Modern-CPP-Programming: Modern C++ Programming Course (C++11/14/17/20) | Federico Busato
https://github.com/federico-busato/Modern-CPP-Programming
Chrome is in the news for another 0-day that makes use of integer overflow in C++.
This is a solvable problem, and these bugs can be eliminated to make software safer by design. Please enjoy a blog post about how!
Unplanned, but I've recently found about about the Entity, Component, System design pattern and found a professor that put his lectures online for making a game engine in C++ using SFML and I've been following along.
I have no plans to do anything with the knowledge or code I write but it makes me really miss being a University student and learning all day.
If anyone finds that sort of thing interesting, here is the playlist on YouTube
https://youtube.com/playlist?list=PL_xRyXins848nDj2v-TJYahzvs-XW9sVV&si=jueh2gwkh3HgJiWb
#cpp #ecs #gamedev #sfml #programming
std::as_const is a C++17 utility that simplifies const-casting, specifically the safe variant of adding a const qualifier.
Notably, this utility is more ergonomic in generic contexts than the standard const_cast.
Compiler Explorer link: https://compiler-explorer.com/z/sP5MeEP6b

✨ Rust std fs slower than Python!? No, it's hardware!
https://xuanwo.io/2023/04-rust-std-fs-slower-than-python/
how to include a c++ library in build.zig
https://zig.news/xq/zig-build-explained-part-2-1850
Discussions: https://discu.eu/q/https://zig.news/xq/zig-build-explained-part-2-1850
Modern C++ Programming Course
https://github.com/federico-busato/Modern-CPP-Programming
Discussions: https://discu.eu/q/https://github.com/federico-busato/Modern-CPP-Programming
🦀 How to use Rust in Chromium

When writing C++, I consistently find myself wanting to use std::string_view, because I want to take a view into a string. Then, as time goes on, I eventually want to pass that string to something which eventually has to interact with a #C (usually #POSIX) API. At that point, I need a 0-terminated string. string_view isn't zero terminated, so I revert back to using a const char * instead of a string_view.
Why oh why isn't there a std::c_string_view which contains a zero-terminated string
Modern C++, especially C++17 and later, is much like German. Both languages meant for people already skilled in them.
At least German has the excuse of being an organically-grown human language.
Storing data in pointers
https://muxup.com/2023q4/storing-data-in-pointers
Discussions: https://discu.eu/q/https://muxup.com/2023q4/storing-data-in-pointers
@CppCon Here are references for the thread above:
* Keynote video: https://youtu.be/I8UvQKvOSSw
* Keynote slides: https://github.com/CppCon/CppCon2023/blob/main/Presentations/Plenary_Delivering_Safe_Cpp.pdf
* Skeleton repository: https://github.com/BjarneStroustrup/profiles
* Memory Safe Languages in Android 13: https://security.googleblog.com/2022/12/memory-safe-languages-in-android-13.html
* Scaling Rust Adoption Through Training: https://security.googleblog.com/2023/09/scaling-rust-adoption-through-training.html
* Bare-metal Rust in Android: https://security.googleblog.com/2023/10/bare-metal-rust-in-android.html
@CppCon At Android, we can see the effects of shifting more and more code to memory safe languages (Java and Rust): https://security.googleblog.com/2022/12/memory-safe-languages-in-android-13.html. The absolute number of critical/high memory safety vulnerabilities was halved from 2019 to 2022. The drop is correlated with the introduction of more and more memory safe code.
It will be very interesting to see the effect of C++ profiles! This assumes they become standardized and widely adopted in the next 5-10 years.
@CppCon There is also a comment about unsafe constructs being unmentioned. Unsafe Rust is part of Rust and I think it's super important that we acknowledge this. The power of unsafe is that it gives us a structured way to build safe abstractions on top of unsafe primitives. The standard library is a great example of this.
However, it's true that it can be hard or impossible to encapsulate program-wide safe effects. See https://security.googleblog.com/2023/10/bare-metal-rust-in-android.html, which touches on this.
@CppCon Rust is not mentioned at all throughout the talk. But Bjarne again points out that any alternative language would need to have interoperability with C and C++. He claims this is often underestimated.
I don't agree with that it is ignored or down-played: Google (and other companies) are investing into Rust and C++ interop, see https://github.com/google/crubit and https://github.com/google/autocxx as important examples of work in this area.
@c_discussions std::vector performing better than any set for small inputs.
C++ std::unordered_set performing worse than a std::set for large inputs
Discussions: https://discu.eu/q/https://cses.fi/problemset/
#algorithms #compsci #cpp #learnmachinelearning #programming
Given all the ad block conversation around YouTube, I wonder what it would take for conferences to post their videos to PeerTube or similar video service. I mean they have the content ready to go.
Various conferences in a topic could even together start their own instance and share the infrastructure cost. There won't be any need for content moderation.
Looking at you Cpp North, C++ on Sea, C++ Now, Meeting CPP, AdaCon, ...
An unsafe Rust can still solve a ton of safety problems, leaving lifetimes to mitigations like smart pointers (like raw_ptr in Chrome). This seems like the viable incremental migration/adoption strategy for Safe Rust. Swift is nailing this. I think Carbon is trying to go this direction too.
Anyway, enjoy an interesting chat with the Swift team manager:
https://mastodon.social/@rust_discussions/111454394522188951
2/2
Swift is getting really mature. Stable ABI. Using clang to access and represent C++ types natively. No ffi bindings required. Foundation library available on all desktop platforms.
I hope Rust will start putting some serious effort behind C++ migration/interop. Or I can see a future where the C++ industry migrates largely to Swift, with perhaps Rust libraries for specific tasks like codecs. Which is fine but I worry about some companies, that would be willing to use Rust, never catching up to that.
C++ code will never migrate directly into Safe Rust. Swift found a middle ground for it that Rust will need too. Unsafe Rust needs to become a language people can do their daily work in that is better than C++. That’s what migration can look like.
I was skeptical of Carbon’s plan to build out an unsafe language that is good to work in, since I felt like the safe language is where people should be. I still worry about coming in and building the safe language later, but I can see the value of making an ergonomic unsafe language (nullability for pointers for example), because they are taking seriously the idea of migrating whole C++ codebases to this language. AND understanding that people will be working in that (unsafe) language full time.
1/2
Thanks to Ryan Jespersen for having me on today to talk about the fall of X, the future of Mastodon, the fate of Bill C-18, the problems with an Alberta Pension Plan, the troubling rise of antisemitism and Islamophobia sparked by the tragedies in Israel and Gaza, AND the #yegquest Henday chicken hunt. https://www.youtube.com/live/ysQ1k2gseCg?si=RbtcaLph6ckmh_3f #Mastodon #C18 #CPP #AlbertaPensionPlan #yeg #Edmonton #Alberta #SenateofCanada #cdnpoli #abpoli #ableg #LRT
So I just had a thing with a constant like:
static const float someConstant = someExpression;
(Yes it should be a constexpr but it isn't. Yet.)
In one build someConstant is calculated compile time and in another build it's calculated runtime, with slightly different floating point results. The difference turned out to be a compiler flag, but not one I guessed:
/JMC
I can't manage to reproduce it in godbolt but it's consistent in my actual code.
More like /JFC amirite
Zig is a significant improvement over C++
...To be honest...
Even C is a significant improvement over C++
Slint 1.3 UI Toolkit Released with Revamped Native Styles
https://slint.dev/blog/slint-1.3-released
Discussions: https://discu.eu/q/https://slint.dev/blog/slint-1.3-released
Engine programmers literally only want one thing and it's fucking disgusting:
> The game has PASSED the Hardware/Software Compatibility and Performance Check with a great majority of systems obtaining excellent performance results.
(Actual results of my work, I am SO proud!!! 🥳)
#GameDev #GameDevelopment #GameProgramming #Gaming #Programming #CPlusPlus #CPP #CPP20 #OpenGL #GameEngine #Performance #Hardware #Software #Compatibility #Graphics #ComputerGraphics
I am working in a project that has bits of #rstats, bits of #python and bits of #cpp and they are all supposed to be united by #ApacheArrow. How do I access externally created Arrow objects in R? Everything that is in https://r4ds.hadley.nz/arrow.html, https://arrow-user2022.netlify.app/ (with huge thanks to @djnavarro), https://arrow.apache.org/cookbook/r (thanks to @nic_crane) talks about creating large Arrow-ish objects in R by reading external data in csv or parquet rather than connecting to the existing Arrow sources.
Apparently popen won't take 65k long command lines on Windows.
Don't ask me how I know.
@SonnyBonds We use C++ bitfields:
```
struct Object {
bool is_active:1 = 0;
bool is_dirty:1 = 0;
}
```
So, each member is just one bit. The default value only works in C++20 but the bitfields are C++11 I think.
What's your favorite way of doing type safe flags in C++? I typically just use some enum/int combo, but it's not really type safe and you can combine flags from different sets.
✨ How Rust can
Facilitate New
Contributors while Decreasing
Vulnerabilities
🦀 1st time contributors to Rust projects are about
70 times less likely to introduce vulnerabilities
than 1st time contributors to C++ project
Cheers people, anyone into C++ #CPP would like to help both the #Python and #Java communities at once?
I have this #jpype issue that affects many Portuguese-speaking users (and I bet, other international users) that have non-ascii chars in their folder names scattered through their OSs.... https://github.com/jpype-project/jpype/issues/1111
This causes trouble for me personally because #py5 depends on jpype and my students have #ThonnyIDE frequently in a directory with non-ascii chars in its path, due to their usernames or on "Área de Trabalho" (desktop)... etc.
Cooperative C++ Evolution – Toward a TypeScript for C++