Intrinsic Currying for C++ Template Metaprograms

Paul, Keir; Andrew, Gozillon; Seyed, Hossein Haeri

Angol nyelvű Tudományos Konferenciaközlemény (Könyvrészlet)
    Azonosítók
    • MTMT: 30647378
    C++ template metaprogramming is a form of strict functional programming, with a notable absence of intrinsic support for elementary higher-order operations. We describe a variadic template metaprogramming library which offers a model of implicitly curried, left-associative metafunction application through juxtaposition; inspired by languages such as Haskell, OCaml and F♯. New and existing traits and metafunctions, constructed according to conventional idioms, seemlessly take advantage of the framework’s features. Furthermore, a distinctive versatility is exposed, allowing a user to define higher-order metafunction classes using an equational definition syntax; without recourse to elaborate nested metafunctions. The primary type expression evaluator of the library is derived from a single application of an elementary folding combinator for type lists. The definition of the fold’s binary operator argument is therefore a focal point; and constructed mindful that substitution failure of a template parameter’s deduced type produces no compilation error. Two distinctive features of C++ metafunctions require particular consideration: zero argument metafunctions; and variadic metafunctions. We conclude by demonstrating characteristics of the library’s main evaluation metafunction in conjunction with the universal property of an updated right-fold combinator, to compose a range of metafunctions including map, reverse, left-fold, and the Ackermann function.
    Hivatkozás stílusok: IEEEACMAPAChicagoHarvardCSLMásolásNyomtatás
    2020-11-24 10:29