Can operators "return" type?
Zhenya
zheny at list.ru
Thu Nov 29 13:40:33 PST 2012
On Thursday, 29 November 2012 at 16:55:01 UTC, bearophile wrote:
> Zhenya:
>
>> It would useful for some my project,if operators could be a
>> template,that "return"
>> type.
>
> D operators are functions, and D functions return values. And
> in D types are not values (unlike Python and several other
> languages), unless you use a Typeinfo or something.
>
> Maybe if you explain better what you are trying to do someone
> will be able to suggest you an alternative solution. D is not
> as flexible as Lisp, but it doesn't lack
> meta-programming/type-processing capabilities.
>
> Bye,
> bearophile
Of course I understand,that type is not value in D.I meant that
maybe we can declare non-function template operators.For example:
struct MyIntType
{
alias int type;
template opSlice()
{
alias type opSlice;
}
More information about the Digitalmars-d-learn
mailing list