boostorg / boostorg/hana

Elide the temporary container created when returning from algorithms

Open
#150 10 comments 0 reactions 0 assignees View on GitHub
enhancement optimization
Dominant language
C++
Stars
1.9k
Forks
225
PR merge metrics
No merged PRs in 30d

Description

When we write something like

``` c++
auto xs = make_tuple(...);
auto ys = transform(xs, f);
```

A temporary tuple is created and then move-assigned to `ys`. This should be elided most of the time, but providing a way to make sure that this is always the case (without relying on the optimizer) would be nice. This can be achieved e.g. by providing mutating algorithms:

``` c++
auto xs = make_tuple(...);
Result ys;

length(xs).times.with_index([&](auto i) {
ys[i] = f(xs[i]);
});
```

There are probably other ways to achieve this too. See the [original discussion](http://thread.gmane.org/gmane.comp.lib.boost.devel/261077/focus=261308) on the Boost.Devel mailing list.

Contributor guide

Open the contributing guide

Research direction

Review the existing algorithm entry points and the linked Boost.Devel discussion first; the issue does not identify files or tests. Compare the proposed mutating algorithms with other approaches, then define the accepted API and establish coverage showing that returning from algorithms does not require the temporary container.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.