Artigo Acesso aberto Revisado por pares

Implementing monads for C++ template metaprograms

2013; Elsevier BV; Volume: 78; Issue: 9 Linguagem: Inglês

10.1016/j.scico.2013.01.002

ISSN

1872-7964

Autores

Ábel Sinkovics, Zoltán Porkoláb,

Tópico(s)

Software Testing and Debugging Techniques

Resumo

C++ template metaprogramming is used in various application areas, such as expression templates, static interface checking, active libraries, etc. Its recognized similarities to pure functional programming languages–like Haskell–make the adoption of advanced functional techniques possible. Such a technique is using monads, programming structures representing computations. Using them actions implementing domain logic can be chained together and decorated with custom code. C++ template metaprogramming could benefit from adopting monads in situations like advanced error propagation and parser construction. In this paper we present an approach for implementing monads in C++ template metaprograms. Based on this approach we have built a monadic framework for C++ template metaprogramming. As real world examples we present a generic error propagation solution for C++ template metaprograms and a technique for building compile-time parser generators. All solutions presented in this paper are implemented and available as an open source library.

Referência(s)
Altmetric
PlumX