diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-08-26 13:08:39 +0200 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-08-26 13:08:39 +0200 |
commit | f526c4c7a7ada1ab534ca0976c7b66718b9a5660 (patch) | |
tree | 68b4db309ee00d3b7ebc1743b4825057b3db7f28 /include/class.h | |
parent | a286c34777e48d59410e7511f52f4a6f08000ba3 (diff) | |
parent | 97bc6757346d394a4b7d5898983be298e0b0ea98 (diff) |
fixed conflict
Diffstat (limited to 'include/class.h')
-rw-r--r-- | include/class.h | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/include/class.h b/include/class.h index e0316df..cffc7bd 100644 --- a/include/class.h +++ b/include/class.h @@ -202,13 +202,39 @@ public: private: /** + * Method to create the object if it is default constructable + * @param orig + * @return Base* + */ + template <typename X = T> + typename std::enable_if<std::is_default_constructible<X>::value, Base*>::type + static maybeConstruct() + { + // create a new instance + return new X(); + } + + /** + * Method to create the object if it is not default constructable + * @param orig + * @return Base* + */ + template <typename X = T> + typename std::enable_if<!std::is_default_constructible<X>::value, Base*>::type + static maybeConstruct() + { + // create empty instance + return nullptr; + } + + /** * Construct a new instance of the object * @return Base */ virtual Base* construct() const override { // construct an instance - return new T(); + return maybeConstruct<T>(); } /** @@ -225,7 +251,7 @@ private: } /** - * Method to clone the object if it is copy constructable + * Method to clone the object if it is not copy constructable * @param orig * @return Base* */ |