Thread overview | ||||||
---|---|---|---|---|---|---|
|
October 07, 2012 Function pointer variable not recognized as function by is-operator | ||||
---|---|---|---|---|
| ||||
The following compiles, which I'm pretty sure must be a bug, right? Just checking to be sure I won't be polluting the bug tracker. void main() { auto f = (int i) {}; static assert (!is(f == function)); // should fail static assert (!is(f == delegate)); } |
October 07, 2012 Re: Function pointer variable not recognized as function by is-operator | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tommi | On Sunday, October 07, 2012 10:25:41 Tommi wrote: > The following compiles, which I'm pretty sure must be a bug, right? Just checking to be sure I won't be polluting the bug tracker. > > void main() > { > auto f = (int i) {}; > static assert (!is(f == function)); // should fail > static assert (!is(f == delegate)); > } It's not a bug. is(f == function) checks for functions, not function pointers. http://stackoverflow.com/questions/11067972 - Jonathan M Davis |
October 07, 2012 Re: Function pointer variable not recognized as function by is-operator | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | On 10/07/2012 10:35 AM, Jonathan M Davis wrote:
> On Sunday, October 07, 2012 10:25:41 Tommi wrote:
>> The following compiles, which I'm pretty sure must be a bug,
>> right? Just checking to be sure I won't be polluting the bug
>> tracker.
>>
>> void main()
>> {
>> auto f = (int i) {};
>> static assert (!is(f == function)); // should fail
>> static assert (!is(f == delegate));
>> }
>
> It's not a bug. is(f == function) checks for functions, not function pointers.
>
> http://stackoverflow.com/questions/11067972
>
> - Jonathan M Davis
>
Actually is(f==function) checks whether or not f is a function type.
The ==function part is unimportant, because f is not even a type.
|
October 07, 2012 Re: Function pointer variable not recognized as function by is-operator | ||||
---|---|---|---|---|
| ||||
Posted in reply to Timon Gehr | On Sunday, October 07, 2012 10:42:49 Timon Gehr wrote:
> On 10/07/2012 10:35 AM, Jonathan M Davis wrote:
> > On Sunday, October 07, 2012 10:25:41 Tommi wrote:
> >> The following compiles, which I'm pretty sure must be a bug, right? Just checking to be sure I won't be polluting the bug tracker.
> >>
> >> void main()
> >> {
> >>
> >> auto f = (int i) {};
> >> static assert (!is(f == function)); // should fail
> >> static assert (!is(f == delegate));
> >>
> >> }
> >
> > It's not a bug. is(f == function) checks for functions, not function
> > pointers.
> >
> > http://stackoverflow.com/questions/11067972
> >
> > - Jonathan M Davis
>
> Actually is(f==function) checks whether or not f is a function type. The ==function part is unimportant, because f is not even a type.
Ah. That's true. I should have caught that. Regardless, the types of function pointers still won't be true for == function - e.g. is(typeof(f) == function) won't be true - because it's checking for functions, not function pointers.
- Jonathan M Davis
|
Copyright © 1999-2021 by the D Language Foundation