I'm **completely blown away** by C++'s std::variant visitor pattern.
How does it work?
How can it work?
Is it black magic?

https://godbolt.org/z/bKddhnjhW

#cpp #cpluscplus

Compiler Explorer - C++ (ARM GCC trunk)

namespace de::uvok::badge { enum class DisplayIndicator { Uninit, None, Advertising, Connected }; } // namespace de::uvok::badge namespace de::uvok::badge { struct Template { uint8_t template_id; }; struct QrCode { std::string content; }; using BleAction = std::variant<std::monostate, Template, DisplayIndicator, QrCode>; struct BlePollResult { BleAction action_value; explicit BlePollResult(Template val) { this->action_value = val; } explicit BlePollResult(DisplayIndicator indicator) { this->action_value = indicator; } explicit BlePollResult(const QrCode &qrCode) { this->action_value = qrCode; } private: BlePollResult() = default; }; void ble_init(); void ble_advertise(); bool ble_is_active(); std::optional<BlePollResult> ble_poll(); void ble_set_image(uint8_t image); } // namespace de::uvok::badge namespace de::uvok::badge { extern const int image_count; void display_init(void); uint8_t display_next(void); uint8_t display_prev(void); uint8_t display_refresh(void); void display_direct(uint8_t num); void display_text(const std::string &text); void display_indicator(DisplayIndicator); } // namespace de::uvok::badge void foo(std::optional<de::uvok::badge::BlePollResult> ble_poll_result) { if (ble_poll_result.has_value()) { std::visit([&](auto&& arg) { using T = std::decay_t<decltype(arg)>; if constexpr (std::is_same_v<T, de::uvok::badge::Template>) { de::uvok::badge::display_direct(arg.template_id); } else if constexpr (std::is_same_v<T, de::uvok::badge::DisplayIndicator>) { de::uvok::badge::display_indicator(arg); } else if constexpr (std::is_same_v<T, de::uvok::badge::QrCode>) { de::uvok::badge::display_text(arg.content); } }, ble_poll_result->action_value); } }

Entrada de Datos. Lenguaje C++

{ROOR} Revista On-line Occam's Razor

Tired: Unnamed namespace
Wired: Untitled namespace

#CPlusCplus

May I make you aware of the phantastic @compiler_explorer, that totally indispensable tool to every software developer - the brainchild of @mattgodbolt ?

I can speak only as an average C++ developer who works at a small company, and who happens to be stranded in the C++ committee.

For my own experiments, I have a personal bookmark in my browser called "C++23 playground" as a starting point for for more elaborate adventures in the C++ lands. May be, it helps you as well:

https://godbolt.org/z/Mz96j16nx

To the best of my knowledge, the provided flags will give you some highly recommended defaults for compiler diagnostics and maximum language conformance, in the three major implementations Clang/libc++, GCC/libstdc++, and MSVC/MS-STL. Maybe you'll get some inspiration for your daily grind.

Please support Matt and the entire CE team 🤘, f.e. by getting some swag that we nerds can proudly present in the public and wear as protective gear ☺️

Visit https://shop.compiler-explorer.com/promo/BLACKFRIDAY 🤩

#cpp #cpp23 #cplusCplus #programming

Compiler Explorer - C++

int main() { constexpr auto toUsAll = "world"; std::println("Hello {}", toUsAll); }

https://www.theregister.com/2025/03/02/c_creator_calls_for_action/
C++ creator Bjarne Stroustrup calls for help to defend programming language from 'serious attacks'

#CPlusCplus #C #rust #programming

C++ creator calls for help to defend programming language from 'serious attacks'

Bjarne Stroustrup wants standards body to respond to memory-safety push as Rust monsters lurk at the door

The Register

Rust does seem to have a lot of nice features. My biggest blocker for me going to Rust from C++ is that C++ has much better support for generic programming. And now that Concepts have landed, I'm not aware of any language that can compete in this area.

#rust #cpp #CPlusCplus #programming #compsci

Alguna vez te has preguntado como implementa los objetos el compilador de #C++ ? En este artículo os lo contamos a través de un curioso ejemplo

#programming #programacion #POO #CPlusCplus #ASM #C #fenomenoextranos #ROOR09

https://ibolcode.net/roor/2025-04-el-asombroso-caso-del-objeto-fantasma

El asombroso caso del objeto Fantasma

El caso que nos ocupa en esta ocasión lo he sacado de una pregunta de <a href="https://es.stackoverflow.com/questions/630810/llamada-a-m%c3%a9todo-de-clase-c-no-instanciada-que-s%c3%ad-funciona">Stack Overflow Español</a> en el que se planteaba como era posible ejecutar un método sobre un objeto que no ha sido instanciado… Es decir, sobre un objeto que no existe… Un objeto fantasma.</p>

{ROOR} Revista On-line Occam's Razor

What is the stock markets least favorite qualifier?
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
volatile 🥁

#CPlusCplus

ISO/IEC JTC1/SC22/WG21 - Papers 2025