Nested Lambda Expressions with Let Expressions in C++ Template Metaprograms

  • Authors:
  • Ábel Sinkovics

  • Affiliations:
  • Department of Programming Languages and Compilers, Eötvös Loránd University, Budapest, Hungary

  • Venue:
  • Electronic Notes in Theoretical Computer Science (ENTCS)
  • Year:
  • 2011

Quantified Score

Hi-index 0.00

Visualization

Abstract

More and more C++ applications use template metaprograms directly or indirectly by using libraries based on them. Since C++ template metaprograms follow the functional paradigm, the well known and widely used tools of functional programming should be available for developers of C++ template metaprograms as well. Many functional languages support let expressions to bind expressions to names locally. It simplifies the source code, reduces duplications and avoids the pollution of the namespace or namespaces. In this paper we present how let expressions can be introduced in C++ template metaprograms. We also show how let expressions can be used to implement lambda expressions. The Boost Metaprogramming Library provides lambda expressions for template metaprograms, we show their limitations with nested lambda expressions and how our implementation can handle those cases as well.