On Tuesday, 2 October 2012 at 01:00:25 UTC, Walter Bright wrote:
Since all you need to do to guarantee compile time evaluation
is use it in a context that requires CTFE, which are exactly
the cases where you'd care that it was CTFE'd, I just don't see
much utility here.
I suppose the most common use case would be efficient struct
literals which are essentially value types but have non-trivial
constructors.
struct Law
{
ulong _encodedId;
this(string state, int year) @aggressive_ctfe
{
// non-trivial constructor sets _encodedId
// ...
}
}
Policy policy = getPolicy();
if( policy.isLegalAccordingTo(Law("Kentucky", 1898)) )
{
// ...
}
I think the function attribute would be the most convenient
solution.
Note that it is also impossible in the general case for the
compiler to guarantee that a specific function is CTFE'able for
all arguments that are also CTFE'able.
I'll have to take your word for it for not knowing enough
(anything) about the subject.