Skip to content

Commit

Permalink
Report an error when passing a pointer to bindInstance(), instead of …
Browse files Browse the repository at this point in the history
…reporting an obscure error later on.

See issue #25.
  • Loading branch information
poletti-marco committed Aug 28, 2016
1 parent dcd6e6e commit feaed5c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion include/fruit/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,13 @@ class PartialComponent {
*/
template <typename AnnotatedType, typename C>
PartialComponent<fruit::impl::BindInstance<AnnotatedType>, Bindings...> bindInstance(C& instance) &&;


// These deleted overloads are to prevent passing a pointer to bindInstance, you should pass a reference instead.
template <typename C>
void bindInstance(C* p) = delete;
template <typename AnnotatedType, typename C>
void bindInstance(C* p) = delete;

/**
* Registers `provider' as a provider of C, where provider is a lambda with no captures returning either C or C* (prefer
* returning a C by value instead of allocating a C using `new C', to avoid the allocation).
Expand Down

0 comments on commit feaed5c

Please sign in to comment.