Hacker News new | past | comments | ask | show | jobs | submit login

C++ templates cannot be implemented purely by text replacement as most of it is type driven.

It is true that you can do anything that templates do by hand, but that's true for any language construct (at the limit you could write asm).




> C++ templates cannot be implemented purely by text replacement as most of it is type driven.

The static types (and constant values in some cases) are the context. That's the "context-sensitive" part of "context-sensitive expansion".

> It is true that you can do anything that templates do by hand, but that's true for any language construct (at the limit you could write asm).

Yes. That's my point. I was replying to someone saying that they could remove a layer of indirection from a linked list by writing a custom data structure that had the next and previous references, and I was pointing out that they're essentially running C++ template expansion by hand. There's nothing surprising there.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: