YesOrNo: useful idiom helper or wanking?
KennyTM~
kennytm at gmail.com
Mon Apr 11 11:51:26 PDT 2011
On Apr 12, 11 02:29, Andrej Mitrovic wrote:
> On 4/11/11, KennyTM~<kennytm at gmail.com> wrote:
>> The idea, IIUC, is to avoid documenting that extra enum type. So, for
>> example,
>>
>> TRange topNCopy(alias less = "a< b", SRange, TRange)
>> (SRange source, TRange target,
>> YesOrNo!"SortOutput" sorted = false);
>>
>> and then we can call it as
>>
>> topNCopy([1,3,5,2,4], result, SortOutput.yes);
>
> But how do you make `SortOutput` known at the calling site?
Right. Andrei's template can't do it. My approach above is simply
declare an undocumented enum, and use YesOrNo as a tag to statically
ensure that enum can take 'no' and 'yes'.
I feel this using type just for documentation is bad.
More information about the Digitalmars-d
mailing list