On 27/09/12 15:01, bearophile wrote:
Tommi:
2) Is it possible to specialize a function based on whether or not the
parameter that was passed in is a compile time constant?
I am interested in this since some years. I think it's useful, but I
don't know if it can be implemented. I don't remembe
On Friday, 28 September 2012 at 17:52:55 UTC, Tommi wrote:
In a perfect world, I think, the compiler would always evaluate
all possible functions at compile-time, given that doing so
would produce a smaller (or equal size) executable than what
not-evaluating-at-compile-time would produce.
Or
One use case I can think of for specializing functions based on
whether or not its arguments are compile-time evaluable:
// Big container that can't be accessed in constant time:
immutable cachedResults = init();
double getResult()
if (areCompileTimeConstants!() == false)
{
return cache
Jacob Carlborg:
I am interested in this since some years. I think it's useful,
but I don't know if it can be implemented. I don't remember
people discussing about this much.
There's the if (__ctfe) hack. Also using only template
parameters will force the function to be CTFE.
This is quite
On 2012-09-27 15:01, bearophile wrote:
Tommi:
2) Is it possible to specialize a function based on whether or not the
parameter that was passed in is a compile time constant?
I am interested in this since some years. I think it's useful, but I
don't know if it can be implemented. I don't remem
Tommi:
2) Is it possible to specialize a function based on whether or
not the parameter that was passed in is a compile time constant?
I am interested in this since some years. I think it's useful,
but I don't know if it can be implemented. I don't remember
people discussing about this much.
On Sunday, 10 June 2012 at 10:16:23 UTC, jerro wrote:
No, but you could wrap it in a template to force it to always
execute at compile time.
So, I just realized, I could have just this one convenience
template that I can use whenever I want to force an expression to
be evaluated at compile-t
On Sunday, 10 June 2012 at 10:23:09 UTC, Timon Gehr wrote:
No there is not. You could use a template that calls a private
function at compile time instead. What is your use case?
I was just thinking about a situation where a property
accessor/mutator methods are not as simple as read/assign va
On 06/10/2012 09:04 AM, Tommi wrote:
Three related questions:
1) Is there a way to force a function to be always executed at compile
time (when it's possible to do so) no matter what context it's called in?
No there is not. You could use a template that calls a private function
at compile ti
1) Is there a way to force a function to be always executed at
compile time (when it's possible to do so) no matter what
context it's called in?
No, but you could wrap it in a template to force it to always
execute at compile time. Of course it could then only be called
at compile time.
2) Is
Three related questions:
1) Is there a way to force a function to be always executed at
compile time (when it's possible to do so) no matter what context
it's called in?
2) Is it possible to specialize a function based on whether or
not the parameter that was passed in is a compile time cons
11 matches
Mail list logo