Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

what happens when prefix a lambda functor with * or + ?

48 views
Skip to first unread message

Shiyao Ma

unread,
Feb 13, 2017, 9:27:43 PM2/13/17
to
Hi,
given the following code:

auto ff = []{};

what's the type of (+ff), and what's the type of (*ff) ?

And what is happening under the hood for `+' and `*' ?


Shiyao

Shiyao Ma

unread,
Feb 14, 2017, 2:29:26 AM2/14/17
to
So to end my own question.
ff implicitly converts to pointer to function.

and the operator+ and operator* accepts function pointer.

Juha Nieminen

unread,
Feb 14, 2017, 6:19:21 AM2/14/17
to
Shiyao Ma <i...@introo.me> wrote:
> auto ff = []{};

A lambda that doesn't capture anything converts implicitly to a regular
function. However, I'm not sure you can assume those operators will work
if the lambda captures something (in which case its type will be some
compiler-specific internal type, possibly some kind of struct, or maybe
some kind of non-function pointer).

Alf P. Steinbach

unread,
Feb 14, 2017, 9:11:51 AM2/14/17
to
On 14.02.2017 04:31, Stefan Ram wrote:
> Shiyao Ma <i...@introo.me> writes:
>> auto ff = []{};
>> what's the type of (+ff), and what's the type of (*ff) ?
>
> void (*)()
> void ()
>
> here (gcc).
>
>> And what is happening under the hood for `+' and `*' ?
>
> The operand of the unary + operator shall have arithmetic,
> unscoped enumeration, or pointer type. So, (+ff) is a
> possible constraint violation, because we cannot prove
> that the closure type has the required properties?
>
> The operand of the unary * operator shall have arithmetic,
> unscoped enumeration, or pointer type. So, (*ff) is a
> possible constraint violation, because we cannot prove
> that the closure type has the required properties?

I haven't tried this but `[]{}` has an implicit conversion to
`void(*)()` so I think probably `*ff` should be valid.


Cheers!

- Alf


Shiyao Ma

unread,
Feb 14, 2017, 10:36:22 PM2/14/17
to
Hi, Steinbach

It seems you received the mail post from "Stefan Ram".

I am on google groups, and it only shows 4 posts here, not containing the one from "Stefan Ram".

What tools are you using to access the news group?


On Tuesday, 14 February 2017 22:11:51 UTC+8, Alf P. Steinbach wrote:
> On 14.02.2017 04:31, Stefan Ram wrote:

Alf P. Steinbach

unread,
Feb 14, 2017, 11:18:23 PM2/14/17
to
On 15.02.2017 04:36, Shiyao Ma wrote:
> Hi, Steinbach
>
> It seems you received the mail post from "Stefan Ram".
>
> I am on google groups, and it only shows 4 posts here, not containing the one from "Stefan Ram".
>
> What tools are you using to access the news group?

You can check that in the headers in the raw text of the message.

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101
Thunderbird/45.7.1

↑ That means I'm using Mozilla Thundebird.

Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail

↑ The first real server (from the right end of the path) is Eternal
September, which means I'm posting, and therefore probably also reading,
via the Eternal September news-server.

In your case the user agent is G2/1.0, which presumably means Google
Groups' online UI, and the first real server in your message's
propagation path is glegroupsg2000goo.googlegroups.com, which delegated
the task further to postnews.google.com.

Cheers & hth.,

- Alf

Scott Lurndal

unread,
Feb 15, 2017, 8:35:11 AM2/15/17
to
Shiyao Ma <i...@introo.me> writes:
>Hi, Steinbach
>
>It seems you received the mail post from "Stefan Ram".

Stefan foolishly adds a "X-No-Archive: yes" header to his
usenet posts, which prevents google from archiving them.

You can see Stefan's posts by using a real usenet server instead
of google groups to read this newsgroup.


0 new messages