Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate variadic templates to decrease code size #9

Open
citibeth opened this issue Jan 19, 2016 · 3 comments
Open

Investigate variadic templates to decrease code size #9

citibeth opened this issue Jan 19, 2016 · 3 comments

Comments

@citibeth
Copy link
Contributor

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
Copy link
Collaborator

lutorm commented Jan 19, 2016

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
Copy link
Contributor Author

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
#9 (comment).

@AnderOne
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants