Earlier quoted context omitted.
Template metaprogramming isn't really suited for this task, the prime sieve here serves only as a proof of concept, meant to show the capabilities of this style. But there are cases where `constexpr` is not applicable, especially when involving type manipulations. On the other hand, C++ template metaprogramming, as an esolang, is fun to tame and experiment with.
Is there a clearer example where constexpr wouldn't work? > On the other hand, C++ template metaprogramming, as an esolang, is fun to tame and experiment with. Is it an esolang at this point? I feel old.
Lisp-style C++ template meta programming
11–18 of 18 posts
Re: Lisp-style C++ template meta programming
#12(And please don't use any of it in any professional context.)
Re: Lisp-style C++ template meta programming
#13In my grad school days, a couple of decades ago, I had written a library for my own use to facilitate chaining of different kinds of numeric operations on data vectors and sequences. Essentially, for a very simple form of deforestation [0,1], equipped with intermediate buffers to facilitate SIMD. GCC, surprisingly, was quite good at generating SIMD code from it and eliminating temporary data vectors. GCC was even qui…
What you did sounds like Eigen, which probably takes expression templates much further than you did due to the long time it's been around. It is weirdly absent from its documentation, but Eigen does have explicit SIMD support for several architectures and SIMD instruction sets. https://libeigen.gitlab.io/
Re: Lisp-style C++ template meta programming
#14In my grad school days, a couple of decades ago, I had written a library for my own use to facilitate chaining of different kinds of numeric operations on data vectors and sequences. Essentially, for a very simple form of deforestation [0,1], equipped with intermediate buffers to facilitate SIMD. GCC, surprisingly, was quite good at generating SIMD code from it and eliminating temporary data vectors. GCC was even qui…
It is pretty well known that C++ templates really are dynamically typed, it's compile time duck typing. What you did sounds like Eigen, which probably takes expression templates much further than you did due to the long time it's been around. It is weirdly absent from its documentation, but Eigen does have explicit SIMD support for several architectures and SIMD instruction sets. https://libeigen.gitlab.io/
This thing I wrote, predated Eigen (by a few years, I think) had a better support for pipelines and dataflow oriented programming (at least in the context of what I needed) than Eigen. It was more like itertools, functools of Python. Likely older than Eigen but positively after Blitz++ because I remember studying Blitz++ code.
Unlike Eigen, mine had no explicit support for intrinsics, for that I relied on a smart enough compiler, GCC was surprisingly good.
Too bad MSVC was quite bad at optimising and inlining away to the expression trees that Eigen (and mine) generated.
Re: Lisp-style C++ template meta programming
#15Re: Lisp-style C++ template meta programming
#16Earlier quoted context omitted.
Template metaprogramming isn't really suited for this task, the prime sieve here serves only as a proof of concept, meant to show the capabilities of this style. But there are cases where `constexpr` is not applicable, especially when involving type manipulations. On the other hand, C++ template metaprogramming, as an esolang, is fun to tame and experiment with.
Is there a clearer example where constexpr wouldn't work? > On the other hand, C++ template metaprogramming, as an esolang, is fun to tame and experiment with. Is it an esolang at this point? I feel old.
Re: Lisp-style C++ template meta programming
#17In my grad school days, a couple of decades ago, I had written a library for my own use to facilitate chaining of different kinds of numeric operations on data vectors and sequences. Essentially, for a very simple form of deforestation [0,1], equipped with intermediate buffers to facilitate SIMD. GCC, surprisingly, was quite good at generating SIMD code from it and eliminating temporary data vectors. GCC was even qui…
Re: Lisp-style C++ template meta programming
#18Ages ago in C++98/03 era, cons based lists were the only way to do type lists or tuples, so solutions like these did see some production use (and yes, it did kill compile time).
Of course these days variadics have made these solutions obsolete.