aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMarco Poletti <poletti.marco@gmail.com>2017-08-13 19:22:07 +0200
committerMarco Poletti <poletti.marco@gmail.com>2017-08-13 19:22:07 +0200
commit4d26bedc39498e1472eb40e84130dff73167c887 (patch)
tree6617e22654567861a2fa8296b06696dd90935998 /examples
parentbdb151a52a38d2c4e6279b7bacfb14ab662b2891 (diff)
downloadgoogle-fruit-4d26bedc39498e1472eb40e84130dff73167c887.tar.gz
Report a compile time error when an class must have a virtual destructor but doesn't have one.
Specifically, the following cases now result in a compile-time error (instead of undefined behavior): * registerProvider() called with a lambda that returns a pointer to an abstract class with no virtual destructor * registerMultibindingProvider() called with a lambda that returns a pointer to an abstract class with no virtual destructor * registerFactory() called with a lambda that returns a std::unique_ptr<T>, with T an abstract class with no virtual destructor * bind<I, C>() used to bind a std::function<std::unique_ptr<I>(Args...)> to a std::function<std::unique_ptr<C>(Args...)> and I doesn't have a virtual destructor
Diffstat (limited to 'examples')
-rw-r--r--examples/scaling_doubles/scaler.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/examples/scaling_doubles/scaler.h b/examples/scaling_doubles/scaler.h
index 036b8e6..58fa48c 100644
--- a/examples/scaling_doubles/scaler.h
+++ b/examples/scaling_doubles/scaler.h
@@ -22,6 +22,8 @@
class Scaler {
public:
virtual double scale(double x) = 0;
+
+ virtual ~Scaler() = default;
};
using ScalerFactory = std::function<std::unique_ptr<Scaler>(double)>;