Expression templates and meta-programming in boost::Spirit

March 25, 2007 at 5:31 PMAmer Gerzic

Introduction

According to one of expression templates inventors, Todd Veldhuizen, expression templates are “new C++ technique for passing expressions as functions arguments” [1]. The purpose of expression template is to inline expressions during compilation, which produces faster and arguably more readable code. Most of expression template articles focus on numeric array classes and operations on those using expression template techniques. For instance, expression templates could be utilized for matrix multiplication without using temporaries. For such article and code examples, please refer to articles referenced under [1] and [2].

As probably suspected, this article will not focus on expression templates as applied on numeric array classes. In this article, the focus will be on parsing and language recognition using expression template techniques. Furthermore the article will focus on Spirit library [3], a parser framework implemented completely using expression templates and template meta-programming. At this point the reader is encouraged to refer to introductory part of Spirit documentation as found here http://www.boost.org/libs/spirit/doc/introduction.html.

In addition it is important to note that this article will not focus on all parts of Spirit framework. This article is rather attempt to explain fundamentals behind expression templates as applied in Spirit framework.
More...

Posted in: CPP

Tags: , , , , , , ,