Problem with CTFE

Sean Kelly sean at f4.ca
Tue Dec 18 11:40:00 PST 2007


Can someone tell me why compiling with version=Good works, but compiling 
with version=Bad fails?

     version( Good )
     {
         size_t find(Elem)( Elem[] buf, Elem pat )
         {
             for( size_t pos = 0; pos < buf.length; ++pos )
             {
                 if( buf[pos] == pat )
                     return pos;
             }
             return buf.length;
         }
     }
     else version( Bad )
     {
         size_t find(Buf, Pat)( Buf buf, Pat pat )
         {
             return 0;
         }
     }

     const pos = find( "abcdefg", 'c' );

     void main()
     {

     }


More information about the Digitalmars-d-learn mailing list