I’ve fallen a bit behind on what the C++ committee is up to these days, but last year I was interested in pushing for better support for macros in C++.
Whenever you say the word macro, a C++ coder will instantly turn up their nose. Macros have a terrible reputation, for a good reason, with the term largely associated with the preprocessor macros – simple text replacements that are abhorrent for proper practices.
That being said, macros are often needed in a C++ program, or any program. C++ gets real ugly sometimes where you want to repeat code for performance, or otherwise you’d like to reduce some boilerplate. I think in most cases you are just doing it wrong, and you should just be using inheritance or similar methods, but I still think macros serve an important purpose to simplify code when needed. That necessity is why preprocessor macros haven’t been completely outlawed.
There are proposals for metaclasses and other compile-time programming methods easing their way into the standard to try and make macros obsolete, but I think these proposals are really going the wrong way about it – just dumping overly complicated (but practical internally) solutions onto the problem. During some conference talks I remember someone saying that C++ macros should be programmed in C++. I really disagree. If something is going to compose your C++ code for you, it should be a scripting language. C++ is not a scripting language. Why would any sane coder want to script their code in tedious C++ where the most basic thing like manipulating a string has tons of caveats? The compiler suffers too, having to interpret C++. Many operations in modern C++ classes depend on tons of optimizations to be efficient.
A real solution that I would like to see is a programmable C++ compiler. Something with proper scripting support which would allow us to reprogram several stages of compilation in any language we want. Just imagine, inserting a properly namespaced macro into your code, having all of the C++ context at that point passed to a Python script along with whatever arguments, and then outputting delicious C++ code from there. This would give a ludicrous amount of power and flexibility to library developers and change the face of C++, shifting a lot of the burden from the committee to the community. Sure it would open the gates of hell to whatever clever ideas the deranged programmer community has, but that’s just a side effect of flexibility.
All that said, C++ compilers are not simple. At all. I’ve poked through the Clang codebase a bit, getting a feel for how these behemoths work, and I’m pretty sure making them programmable like that is a shitload of work. :)