[dune-functions] performance impact of std::bind
Christian Engwer
christian.engwer at uni-muenster.de
Sun Sep 27 14:07:20 CEST 2015
On Sun, Sep 27, 2015 at 12:16:18PM +0200, Steffen Müthing wrote:
>
> > Am 26.09.2015 um 21:40 schrieb Christian Engwer <christian.engwer at uni-muenster.de>:
> >
> > Dear fellow dune-functions fans :-)
> >
> > While trying to push our functions interfaces to the extrem I was
> > wandering, what the performance impact of std::bind is.
> >
> > Does anybody have some insights?
>
> I don’t have any hard measurements, but I would think that it’s negligible as long as the
> curried parameters don’t have to be copied into the bind functor in an expensive fashion.
I hoped for the same thing, but as the standard doesn't seem to
require too much, I was rather unsure. On the other hand I don't
need to/can use std::bind anymore, so the initial question got kind of
obsolete (see further below).
> Slightly off-topic: I read somewhere that some parts of the committee consider std::bind mostly
> obsolete with the advent of generic lambdas…
That is true, but it will take some time, until we can use generic
lambda :-)
... and now ... why I decided not to use std::bind ...
What I wanted to achieve is to do something as follows:
// create a free function, in a local context
f = [] (const Entity & e, LocalDomain x) { return x.two_norm(); }
// bind the entity to an entity in a wrapper class
...
const Entity * e_;
...
f2 = magically_bind_parameter(_1,std::cref(*e_));
...
At this place I can't use std::bind, as bind wants an explicit
statement for _all_ parameters:
std::bind(std::cref(*e_),_2);
which is hard to achieve in a generic fashion. I now cooked up
something homebrewn, where I just state that a particular parameter
has to replaced with the value of f2.bind(e).
Ciao
Christian
More information about the dune-functions
mailing list