C++ Templates are Turing Complete

January 13, 2006 @ 11:25 | In Programming | | del.icio.us digg devbump rss

Reading one of the latest books of Scott Meyers I discovered that C++ templates have been proved to be Turing Complete. Turing Complete means that C++ templates can emulate a Turing Machine, so they can execute any algorithm (of course, in a theory world because for example Turing Machines have unlimited storage capacity). This means that you can metaprogam with templates anything you can code in C++. Obviously this doesn’t say anything about how to implement it or how easy it would be. In theory you could, for example, run a OS like Windows using a C++ compiler as a MetaOS. :)

I always found C++ Metaprogramming a little bit hacky. If you are interested, this is a paper demonstrating the Turing-completeness of C++ templates.





Wed, 20 Aug 2008 20:07:53 +0200 / 25 queries. 1.407 seconds / 4 Users Online

gentoo link wordpress link apache link PHP link website stats

Theme modified from Pool theme. Valid XHTML and CSS