C++ Logo

sg7

Advanced search

Re: [SG7] string. vector vs string_view, span in reflection API

From: Peter Dimov <pdimov_at_[hidden]>
Date: Mon, 12 Apr 2021 20:34:21 +0300
Jean-Baptiste Vallon wrote:
> This is true — looping over the entire members_of, with a condition
> inside, seems to be 2-3x slower in this example:
>
> https://cppx.godbolt.org/z/bxGhGPfKo
>
> Presumably this is due to the cost of instantiating each body of the
> `template for`, which involves considerable allocations of its own internally
> (e.g. lots of Stmt::Create(…) inside clang).
>
>
> David : I am unable to reproduce your results (the left side with a condition
> inside the loop is faster for me, which i think wasn't what you meant?).
> Also, the template for is not needed here, but replacing it by a simple for
> doesn't change the result (i suppose the compiler doesn't instantiate any
> statements since the body of the loop can simply be evaluated).

Left side isn't faster for me. However, both functions return 0, which means
something isn't right. https://cppx.godbolt.org/z/bGcP848zh

Received on 2021-04-12 12:34:25