"Fossies" - the Fresh Open Source Software Archive

Member "ldc-1.10.0-src/tests/d2/dmd-testsuite/fail_compilation/imports/a11850.d" (19 Jun 2018, 743 Bytes) of package /linux/misc/ldc-1.10.0-src.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) D source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 //import std.array, std.range;
    2 module imports.a11850;
    3 
    4 
    5 template filter(alias pred)
    6 {
    7     auto filter(Range)(Range rs)
    8     {
    9         return FilterResult!(pred, Range)(rs);
   10     }
   11 }
   12 
   13 
   14 private struct FilterResult(alias pred, Range)
   15 {
   16     alias Range R;
   17     R _input;
   18 
   19 
   20     this(R r)
   21     {
   22         _input = r;
   23         while (_input.length != 0 && !pred(_input[0]))
   24         {
   25             _input = _input[1..$];
   26         }
   27     }
   28 
   29 
   30     auto opSlice() { return this; }
   31 
   32 
   33     @property bool empty() { return _input.length == 0; }
   34 
   35 
   36     void popFront()
   37     {
   38         do
   39         {
   40             _input = _input[1..$];
   41         } while (_input.length != 0 && !pred(_input[0]));
   42     }
   43 
   44 
   45     @property auto ref front()
   46     {
   47         return _input[0];
   48     }
   49 }
   50 
   51