equivariant functions

Denis Koroskin 2korden at gmail.com
Sun Oct 12 14:27:42 PDT 2008


On Mon, 13 Oct 2008 01:17:36 +0400, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:

> Denis Koroskin wrote:
>> May I suggest one of my personal preference? Here it is:
>>  sameconst(char)* strstr(sameconst(char)* str1, const(char)* str2)
>> {
>>     return str2; // compile-time error. Can't cast const(char)* to  
>> sameconst(char)* implicitly
>> }
>
> I prefer my solution because it's more general and addresses more issues  
> than passing the qualifier out.
>
> Andrei

Yes, my solution doesn't address clone() method return type, but I think  
they aren't related.

Besides, your solution can't implement the following example, so mine is  
more flexible: :)

sameconst(char)[] findPatternInS1OrS2(sameconst(char)[] s1,
	sameconst(char)[] s2, string needle);



More information about the Digitalmars-d mailing list