We need better documentation for functions with ranges and templates

Ali Çehreli via Digitalmars-d digitalmars-d at puremagic.com
Mon Dec 14 13:02:05 PST 2015


On 12/14/2015 12:53 PM, Andrei Alexandrescu wrote:

 > I'm thinking along the lines of:
 >
 > * Change ddoc to output the constraint separately under a
 > DDOC_CONSTRAINT macro.
 >
 > * Allow ddoc comments inside macros:
 >
 > bool isSameLength(Range1, Range2)(Range1 r1, Range2 r2)
 > if (isInputRange!Range1 && isInputRange!Range2 && !isInfinite!Range1 &&
 > !isInfinite!Range2
 > /**
 > `Range1` and `Range2` must be both non-infinite input ranges.
 > */
 > );

Can we simplify it even more? Just this much:

     bool isSameLength(Range1 r1, Range2 r2)

Then some text that follows:

     Range1 is a template parameter:
         default value: blah

     Range2 is a template parameter

     Template constraints:

         if (isInputRange!Range1 &&
             isInputRange!Range2 &&
             !isInfinite!Range1 &&
             !isInfinite!Range2)

There can be a hover-over or a click to see the full signature.

Ali



More information about the Digitalmars-d mailing list