[PATCH] D55045: Add a version of std::function that includes a few optimizations.

Louis Dionne via Phabricator reviews at reviews.llvm.org
Mon Dec 3 06:03:25 PST 2018

ldionne added a comment.

In D55045#1315541 <https://reviews.llvm.org/D55045#1315541>, @EricWF wrote:

> In D55045#1314652 <https://reviews.llvm.org/D55045#1314652>, @jsoyke wrote:
> > FWIW, I'm slightly in favor of using different headers. For example, I just realized that this change currently leaves a bunch of baggage symbols laying around that the new code won't use, it would be easier to see that kind of thing if the internals of each function were just in it's own file.
> I'm strongly against it. The harder it is to see all the implementations of a given function `f`, the harder it is to know they exist and keep them in sync. In my experience spreading these things out leads to real bugs.

If you can test both implementations against the same set of tests, it shouldn't be hard to catch those bugs. Actually, that would be better than having only one version of the code tested (because let's face it, most people are not going to run the tests with both configurations, they're only going to use the default one).

> @ldionne wrote:
>> This is why I would like for us to plan on a solution that is more easily maintainable in the face of N implementations, not just 2 implementations (disregarding the C++03 implementations).
> I would like that too. but that's not a blocking issue on this review.

It is a blocking issue if we're going to interleave the code with `#ifdef`s, as it makes the transition to a solution where we can maintain N implementations more difficult.

> I also don't agree that we'll see more `std::function` implementations in the future. We won't. We're not going to standardize additional features to `std::function` unless they're not ABI breaking. That is, if the standard does `function` it'll won't require another version of it.
>  Maybe you were thinking about things like `std::unique_function`?

No, what I mean is that libc++ might want to provide different implementations of `std::function`, for example with different SBO sizes. The fact that @jsoyke seems to have many different implementations of `std::function` laying around is a validation of my hypothesis that we may want to have more than one `std::function` implementation.

  rCXX libc++



More information about the libcxx-commits mailing list