google / google/fruit

Passing reference parameters to get*Component functions doesn't work

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

Description

Test case:

```
#include
fruit::Component getRootComponent(int& n) {
return fruit::createComponent().bindInstance(n);
}
static int n = 3;
int main() {
fruit::Injector injector(getRootComponent, n);
injector.get();
}
```

It should work, or at the very least it should fail with an error message mentioning this workaround:

```
#include
fruit::Component getRootComponent(int* n) {
return fruit::createComponent()
.bindInstance(n);
}
static int n = 3;
int main() {
fruit::Injector injector(getRootComponent, &n);
injector.get();
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.