C++23 will be officially released later this year but is already complete. Explore how the latest C++ standard helps write modern, efficient, robust, & future-proof code with Giuseppe D'Angelo at the KDAB Training Day on November 27th. #cpp #cplusplus
I received the Best Speaker Award from ESE Kongress for my talk C++ 20 Templates - Die na虉chste Generation.
#AwardWinning #cpp20 #cpp #cplusplus
#239 Given the following in C++:
constexpr const char *x = "Hello World";
constexpr const char *y = "Hello World";
constexpr bool b = x == y;
Without checking, is this well-formed?
A. Yes
B. No
C. Show results
Constants can sometimes help find (certain) errors at compile time instead of runtime: constexpr over const variables; const variables over non-const variables; and macros or literals if you must.
Obviously, constants don't always provide this benefit, but strive to use them where opportunity permits.
Example: https://sigcpp.godbolt.org/z/sjd5vWrPn
(Also, avoid "naked new", but that's for another time.)
#cpp #cplusplus #programming #software #softwarequality
I will be speaking at NDC TechTown 2023! The talk's title is "C++ Coroutines from scratch". Come and join me there!
https://ndctechtown.com/agenda/c-coroutines-from-scratch-0mqw/0n2r6pkwh1g
The std::queue is a container adapter that implements the interface of a FIFO queue.
The options for the backing containers are std::deque and std::list.
Compiler Explorer link: https://compiler-explorer.com/z/5Gbo53hMx
#cpp #cplusplus #coding #programming #dailybiteofcpp
#cpp connoisseurs, may I ask you for a favour and vote for this bug report on DevCom if you happen to care about #modules ?
https://developercommunity.visualstudio.com/t/CPreprocessor-Ill-formed-code-is-a/10461894
[Certificazioni] Python Institute
Ieri su /c/informatica si parlava di universit脿 e certificazioni cos矛 ne approfitto per condividere questo link. Sul sito si trovano i corsi gratuiti utili a preparare il percorso di Python, C/C++, JavaScript e persino un corso di Inglese per IT.
Oltre a essere gratuiti ho letto in rete che, al completamento, viene offerto un voucher sconto per gli esami di certificazione.
#programmazione #python #cplusplus
An illustration, a couple of exercises, and an example comparing references in C++ and Java (and Python). 鈽濓笍
(This is also when I wish more students were on Mastodon/Fediverse. I don't know but we need to collectively work on that.)
#cpp #cplusplus #java #python #programming #education #teaching #learning #student #students
#cpp #cplusplus #java #python #programming #education #teaching #learning #student #students
Selected slides from my presentation comparing references in C++ and Java.
#cpp #cplusplus #java #programming #education #teaching #learning
#cpp #cplusplus #java #programming #education #teaching #learning
In retrospect, how I wish C++ used the term "alias" instead of "reference" to be very clear that a pointer or similar underlying mechanism, including storage" is not necessary.
"It is unspecified whether or not a reference requires storage."
https://eel.is/c++draft/dcl.ref#4
The issue now (and not really C++'s fault) is that people coming from a language like Java hear "reference" and think it works the same way in C++ as it does in Java. Especially reference parameters. 馃様
If we want to iterate over the elements of a bidirectional range in reverse order, we do not have to mutate it.
However, if we do want to mutate the range, we can use the std::reverse algorithm.
Note that std::list and std::forward_list provide a reverse method that reorders the nodes (instead of reversing the order of the values).
Compiler Explorer link: https://compiler-explorer.com/z/PEvznc99o
#cpp #cplusplus #coding #programming #dailybiteofcpp
Check out my post, "A string class that is only instantiable at compile-time", you learn how to have a class that s only instantiable at compile-time.
https://andreasfertig.blog/2023/01/a-string-class-that-is-only-instantiable-at-compile-time/
Do you think it's worth spending time studying the C programming language today, considering that #Rust addresses and improves upon many of the fundamental issues found in #C and #cplusplus?? Why?
Despite recent developments (<format> and <print>), iostreams will be with us for the foreseeable future.
One of the quirks of iostreams is their approach to error handling, with errors represented using flags and error states.
Compiler Explorer link: https://compiler-explorer.com/z/eh5noa66f
#cpp #cplusplus #coding #programming #dailybiteofcpp
I'm proud of my #memgraph changes today. Fixing some small #cpp #cplusplus issues. Now a simple query just got ~80% faster.
Not bad for a +23 -13 change https://github.com/memgraph/memgraph/pull/1227
Before C++20, using common mathematical constants relied on either POSIX or a compiler extension through the <math.h> header.
C++20 introduced a new <numbers> header that provides common mathematical constants as templates that can be specialized for user types. The standard library provides float, double and long double specialisations with an alias for the double variant.
Compiler Explorer link: https://compiler-explorer.com/z/9rd5neahn
#cpp #cplusplus #coding #programming #dailybiteofcpp
Tuesday common C++ interview problem: Calculate h-index.
Given information about research paper citations as std::vector<int>, where each element represents the number of citations for a paper, calculate the h-index: https://en.wikipedia.org/wiki/H-index.
Your solution should run in O(n).
Solve it yourself: https://compiler-explorer.com/z/5K5Wv1ha9
Solution: https://compiler-explorer.com/z/9efEYcor9
#cpp #cplusplus #coding #programming #dailybiteofcpp
Tip 21 of #TuesdayCodingTips - Dangers of Enums
C++ and C# have a caveat in their enum types. Each enum has an underlying storage type which limits a maximum number of values and how much space it takes in memory. However, it also works the other way - it says how many values the enum handles.
If you define an enum with just three values, if it has an underlying type of uint8, it handles 256 distinct values. You can take any integer up to 255, cast it to that enum type, and get a "valid" enum value. When branching on an enum, you need to keep in mind that you might get an undefined enum value, especially if it was deserialized from the wire.
To add insult to injury, compilers won't warn you by default. Only the pattern matching does for C#. C++ can warn you if you don't cover a defined enum value in a switch statement, but you must not use the default case - preventing you from correctly handling ill-formed values.
#tuesdaycodingtips #programming #cplusplus