This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: implementation & optimization of std::function with and without allocator

On 25 January 2014 16:00, Basile Starynkevitch wrote:
> First, my understanding of the C++11 standard thru
> (which I know is imperfect, but I find it much more readable than
> n3337.pdf draft of C++11 ....)
> is that in principle we should compile this code with the #if 0 replaced
> by #if 1 (but we don't yet, our <functional> header says "TODO: needs
> allocator_arg_t"). Perhaps the type of mygcalloc is wrong...
> (I don't understand at all the issues of accepting allocators for
> std::function)

Using allocators with std::function isn't supported yet. This is
documented at
(and looking at the code, as you have done, should make it pretty
clear the necessary constructors are not defined).

> Then, I am surprised (and a bit disappointed) that (using GCC 4.8.2 from
> Debian) with
>    g++-4.8  -Wall -std=c++11 -O3 -S \
>            -fdump-tree-phiopt -fverbose-asm
> we are not inlining all the lambda stuff. I was expecting we'll do the
> inlining, since similar experiments with std::array etc...

That isn't similar and the use of std::array is irrelevant.
std::function involves type erasure, usually dynamic allocation, and
indirection through function pointers. If you don't use std::function
then none of that needs to be optimised away.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]