On this page
  1. C-Style Casts (Legacy)
  2. Prefer Instead
  3. Why It Is Legacy in C++

C-Style Casts (Legacy)

Prev: C++ Named Casts | Up: builtins | Next: stdlib
Rel: C++ Named Casts
Ref: ISO C++ Core Guidelines — Avoid Casts
Tags: #public #prog #cpp #builtins #tier/legacy


Prefer Instead

Prefer C++ Named Casts (static_cast, std::bit_cast, dynamic_cast, const_cast) instead of C-style (T)expr casts.

Why It Is Legacy in C++

A C-style cast (TargetType)expr silently tries const_cast, static_cast, static_cast + const_cast, and reinterpret_cast in sequence until one compiles. It can accidentally strip const or reinterpret unrelated pointers during refactoring—and is nearly impossible to grep for in a large codebase.

Linked from

Related notes