aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMarco Poletti <poletti.marco@gmail.com>2014-10-04 13:30:55 +0100
committerMarco Poletti <poletti.marco@gmail.com>2014-10-04 13:39:56 +0100
commit1072a681ce25a84f9b6ebd5b789eb18cce34b2d3 (patch)
tree91bbef159b4180274b945ba09216bc843da76e73 /examples
parent4406e32895ab2682c68436f68c462c7a9f51eff9 (diff)
downloadgoogle-fruit-1072a681ce25a84f9b6ebd5b789eb18cce34b2d3.tar.gz
Allow lambdas used as providers/factories to be inlined in the create() operation, by pushing down the lambda type in the call hierarchy instead of casting it to a function pointer.
Diffstat (limited to 'examples')
-rw-r--r--examples/benchmark/benchmark_small.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/examples/benchmark/benchmark_small.cpp b/examples/benchmark/benchmark_small.cpp
index 814d018..b881e55 100644
--- a/examples/benchmark/benchmark_small.cpp
+++ b/examples/benchmark/benchmark_small.cpp
@@ -30,8 +30,20 @@ X7,
X8,
X9,
X10
-> getComponent() { return fruit::createComponent(); }
+> getComponent() { return fruit::createComponent().registerProvider([](){return Y1();}); }
int main() {
+ fruit::NormalizedComponent<
+ X1,
+ X2,
+ X3,
+ X4,
+ X5,
+ X6,
+ X7,
+ X8,
+ X9,
+ X10
+ > normalizedComponent(getComponent());
for (int i = 0; i < 1000; i++) {
fruit::Injector<
X1,
@@ -44,7 +56,7 @@ X7,
X8,
X9,
X10
-> injector(getComponent());
+> injector(normalizedComponent, fruit::createComponent());
injector.get<X1*>();
injector.get<X2*>();
injector.get<X3*>();