Passing reference parameters to get*Component functions doesn't work
poletti-marco opened this issue · 0 comments
poletti-marco commented
Test case:
#include <fruit/fruit.h>
fruit::Component<int> getRootComponent(int& n) {
return fruit::createComponent().bindInstance(n);
}
static int n = 3;
int main() {
fruit::Injector<int> injector(getRootComponent, n);
injector.get<int>();
}
It should work, or at the very least it should fail with an error message mentioning this workaround:
#include <fruit/fruit.h>
fruit::Component<int> getRootComponent(int* n) {
return fruit::createComponent()
.bindInstance(n);
}
static int n = 3;
int main() {
fruit::Injector<int> injector(getRootComponent, &n);
injector.get<int>();
}