| Thread overview | |||||
|---|---|---|---|---|---|
|
August 23, 2013 InExpression with custom type? | ||||
|---|---|---|---|---|
| ||||
Attachments:
| Hello!
Is it possible to make an InExpression work with a used-defined type?
struct MyCollection { ... }
MyCollection mc;
auto p = 123 in mc;
if (p) { ... }
Thanks!
LMB
| |||
August 23, 2013 Re: InExpression with custom type? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Leandro Motta Barros | On Friday, 23 August 2013 at 19:57:42 UTC, Leandro Motta Barros wrote:
> Hello!
>
> Is it possible to make an InExpression work with a used-defined type?
>
> struct MyCollection { ... }
>
> MyCollection mc;
>
> auto p = 123 in mc;
> if (p) { ... }
>
> Thanks!
>
> LMB
Yes, use opBinaryRight:
T* opBinaryRight(stirng op : "in")(...)
| |||
August 23, 2013 Re: InExpression with custom type? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Namespace Attachments:
| Thanks!
LMB
On Fri, Aug 23, 2013 at 4:59 PM, Namespace <rswhite4@googlemail.com> wrote:
> On Friday, 23 August 2013 at 19:57:42 UTC, Leandro Motta Barros wrote:
>
>> Hello!
>>
>> Is it possible to make an InExpression work with a used-defined type?
>>
>> struct MyCollection { ... }
>>
>> MyCollection mc;
>>
>> auto p = 123 in mc;
>> if (p) { ... }
>>
>> Thanks!
>>
>> LMB
>>
>
> Yes, use opBinaryRight:
>
> T* opBinaryRight(stirng op : "in")(...)
>
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply