From aa7830d0207481eda58ef5474ecad0792675cf43 Mon Sep 17 00:00:00 2001 From: Frank Gaede <frank.gaede@desy.de> Date: Tue, 13 Aug 2019 11:56:48 +0200 Subject: [PATCH] fix optional use of boost::any --- DDCore/include/DD4hep/Plugins.h | 4 +++- DDCore/src/Plugins.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/DDCore/include/DD4hep/Plugins.h b/DDCore/include/DD4hep/Plugins.h index f914431fe..3b99ef7ad 100644 --- a/DDCore/include/DD4hep/Plugins.h +++ b/DDCore/include/DD4hep/Plugins.h @@ -23,13 +23,15 @@ #include <typeinfo> #if __cplusplus >= 201703 -# include <any> +#include <any> +inline bool any_has_value(std::any a){ return a.has_value(); } #else # include <boost/any.hpp> namespace std { using boost::any; using boost::any_cast; using boost::bad_any_cast; + inline bool any_has_value(std::any a){ return !a.empty(); } } // namespace std #endif diff --git a/DDCore/src/Plugins.cpp b/DDCore/src/Plugins.cpp index 6b6bcd062..6326df2ef 100644 --- a/DDCore/src/Plugins.cpp +++ b/DDCore/src/Plugins.cpp @@ -157,7 +157,7 @@ void PluginService::print_bad_cast(const std::string& id, str << "Factory requested: " << id << " (" << typeid(signature).name() << ") :" << msg; printout(ERROR,"PluginService","%s", str.str().c_str()); str.str(""); - if ( !stub.has_value() ) { + if ( !any_has_value(stub) ) { str << "Stub is invalid!"; printout(ERROR,"PluginService","%s", str.str().c_str()); } -- GitLab