Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 33,119 of 33,346    |
|    K. Frank to All    |
|    What are some simple, practical examples    |
|    12 Jul 13 01:56:59    |
      From: kfrank29.c@googlemail.com              Hello Group!              What are some simple examples that illustrate the benefits       of template metaprogramming?              What I have in mind would be examples that "speak to"       programmers (like me) who don't have much experience       with template metaprogramming.              I'm looking for relatively simple programming challenges       that most programmers would have encountered for which       template metaprogramming would offer a good -- or even       compelling -- solution.              So the classic textbook example of calculating factorials       at compile time, while cool, isn't really a good example       in this sense because it's contrived.              By way of analogy, for templates (not metaprogramming) I       think that basic template functions like sort and max, and       template containers are very good illustrations of the       practical utility of templates. (Prior to templates,       many programmers had written qsort wrappers, MIN / MAX       macros, and type-specific containers or used generic       containers that held pointers-to-base such as the old       Rogue Wave tools.h++ RWCollectable containers. So when       templates came along, their benefits were readily       appreciated.)              I'm aware of things like the boost/spirit parser generator       and the boost/msm state-machine framework. These are probably       not great examples because your typical programmer has not       tried to implement a parser generator or state-machine       framework (although he might have used one), so he probably       doesn't have a good feel for what the challenges are and       why template metaprogramming helps.                     Thanks for any examples or other wisdom.                     K. Frank                     --        [ See http://www.gotw.ca/resources/clcm.htm for info about ]        [ comp.lang.c++.moderated. First time posters: Do this! ]              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca