Anyone know why this CTFE isn't working?
Jonathan M Davis
jmdavisprog at gmail.com
Fri Jul 16 03:05:02 PDT 2010
On Friday 16 July 2010 02:46:48 Rory McGuire wrote:
> import std.stdio;
>
> struct State {
> string s; string getString() { return s; }
> static State opCall(string s) {
> State ret;
> ret.s = s;
> return ret;
> }
> }
>
> void main() {
> auto s = State("adf");
> pragma(msg, s.getString());
> }
Make s an enum and it'll work. As it is, it's a local variable created at
runtime rather than a constant at compile-time. So, use
enum s = State("adf");
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list