I needed to help my students visualize struct layout and padding bytes, so I created a C++20 pretty printer (see picture).
Available below, use/improve it as you like!
#cpp#cpp20#metaprogramming#reflection
#109 Given the following in C++20:
constexpr int f() {
int a = 123;
using T=int;
a.~T();
return a;
}
Without checking, is the following well-formed?
static_assert(f() == 123);
A. Yes
B. No
C. Undefined behavior
D. Help! Show me the results!
#Cplusplus#Cpppolls#Cpp20
Please have a look at the updated description of the new book:
Data Member Initialization in Modern C++
Around 50 examples, 2 quizzes, and several exercises of Modern C++ techniques related to data members and how to initialize them safely.
#cpp#cpp20
The Final Version of my C++20 Book
This update includes restructured chapters, more detailed information, and additional examples. The book now has almost 700 pages and more than 200 examples.
Get more information here:
#cpp#cplusplus#cpp20
#115 Given the following in C++20:
struct B {
enum class E {x};
};
struct C {
using enum B::E;
void f(E e){ // 1
int y = static_cast<int>(x); // 2
}
};
Without checking, which marked lines are well-formed:
A. Both
B. 1
C. 2
D. Show results
#Cplusplus#Cpppolls#Cpp20