blitzpp / blitz

Blitz++ Multi-Dimensional Array Library for C++
https://github.com/blitzpp/blitz/wiki
Other
403 stars 83 forks source link

Investigate variadic templates to decrease code size #9

Open citibeth opened 8 years ago

citibeth commented 8 years ago

Peter Boyle wrote:

Just a small comment — I’m working on a distributed MPP cartesian grid code.

github.com/paboyle/Grid

Certainly not pitching it as it is niche, focussed on particle physics, but I found C++11 does enable MUCH smaller more compact expression template engines ~ 250 LOC. Something I learned from Antonin Portelli, CC’d. The corresponding C++98 US QDP++ package was more like 100k LOC using PETE.

So I agree that there is VERY much scope for a rewrite/update using features that were not originally available.

lutorm commented 8 years ago

I agree that with C++11 much ugliness could be removed. Just being able to use "auto" for types would probably cut the code in half... ;-)

Two points, however:

  1. Not everyone can use C++11, so before we drop support for C++98 I think it's worth thinking about things that can be improved/fixed in the current code base.
  2. We should not rewrite the code just because we can. It would be a big project, and we'd go from a fairly well-tested and user-proven code base to a new one, with new and unknown bugs. If we decide to start working on this, we should make sure there's enough people that are committed to seeing it through that we don't end up with something half-completed.
citibeth commented 8 years ago

I agree, moving to variadic templates is low priority at this point. And a C++98 compatible version (1.0) needs to be released and supported before C++11-only versions (2.0) are produced.

On Tue, Jan 19, 2016 at 1:08 PM, lutorm notifications@github.com wrote:

I agree that with C++11 much ugliness could be removed. Just being able to use "auto" for types would probably cut the code in half... ;-)

Two points, however:

  1. Not everyone can use C++11, so before we drop support for C++98 I think it's worth thinking about things that can be improved/fixed in the current code base.
  2. We should not rewrite the code just because we can. It would be a big project, and we'd go from a fairly well-tested and user-proven code base to a new one, with new and unknown bugs. If we decide to start working on this, we should make sure there's enough people that are committed to seeing it through that we don't end up with something half-completed.

— Reply to this email directly or view it on GitHub https://github.com/blitzpp/blitz/issues/9#issuecomment-172936829.

AnderOne commented 5 years ago

This PR (#117) demonstrates case when variadic templates may be helpful for a checking function arguments in compile time. We can't check all possible mixtures of argument types without them.

For example:

A(Range, Range)
A(int, Range)
A(Range, int)
A(int, int)

For Array<T, N> we will get 2^{N} different specializations!