12
Metaprogramming with Macros
Metaprogramming is the practice of writing code that generates or manipulates other code. In many programming languages, metaprogramming capabilities rely on a type of macro expansion system. Macros are a powerful tool in many programming languages, including C++, where they function as a system to generate code through expansion and replacement of text.
The Rust macro system is fundamentally different from C++, and it gives programmers a great deal of additional power. In fact, the Rust macro system encompasses several different types of macros, divided into the categories of declarative macros and procedural macros. This chapter examines the differences between C++ and Rust's macro systems and shows several examples ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access