Le 04/02/2012 07:39, Jonathan Bober a écrit :
For another example: I recently tried to compile some of my own code using
clang++ and discovered that I am not allowed to do

void f(int j) {
     complex<double> x[j];
     [...]
}

even though g++ accepts that. ( See
http://clang.llvm.org/compatibility.html#vla ) Now, I have a few options. I
could allocate everything on the heap explicitly; I could use
vector<complex<double> >; or I could specify a maximum size for j. All of
these options are bad for me, because I care very much about speed, and
I know that j is small, and 99% of the time it will be less that 20, but I
don't want to always allocate space for j = 100 because this is very
rare. So
I have to consciously decide what to do, and if I decide to stick with the
nonstandard gcc extension it is not because I am an idiot but because it is
probably the fastest/easiest option on what is likely to be the only
compiler I ever care about.

If the "j" in question is always a constant in the code (I mean if you always have "f(2)", "f(156)" and the like), you may perhaps consider a template : http://stackoverflow.com/questions/499106/what-does-template-unsigned-int-n-mean

Snark on #sagemath

--
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to