From 1ee545ad68e50aad2b8d51ce23e9afd0b7200df9 Mon Sep 17 00:00:00 2001 From: Christoph Lehmann <christoph.lehmann@ufz.de> Date: Sat, 23 Apr 2016 12:22:14 +0200 Subject: [PATCH] [BL] prevent passing temporaries to ConfigTree ctor --- BaseLib/ConfigTree.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/BaseLib/ConfigTree.h b/BaseLib/ConfigTree.h index e4041229fe1..e2f637ba46f 100644 --- a/BaseLib/ConfigTree.h +++ b/BaseLib/ConfigTree.h @@ -256,9 +256,16 @@ public: * i.e., warnings will also result in program abortion! */ explicit ConfigTree(PTree const& tree, - std::string const& filename, - Callback const& error_cb, - Callback const& warning_cb); + std::string const& filename, + Callback const& error_cb, + Callback const& warning_cb); + + /*! This constructor is deleted in order to prevent the user from passing + * temporary instances of \c PTree. + * Doing so would lead to a dangling reference \c _tree and to program crash. + */ + explicit ConfigTree(PTree&&, std::string const&, + Callback const&, Callback const&) = delete; //! copying is not compatible with the semantics of this class ConfigTree(ConfigTree const&) = delete; -- GitLab