diff --git a/DDCore/include/DD4hep/Plugins.h b/DDCore/include/DD4hep/Plugins.h
index f914431fe6b27814992066e1128e41636a57839d..3b99ef7ad995ec89eb4c15c3eec2e7da6a183ffe 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 6b6bcd0625531e12dda70052969aacb09043f037..6326df2ef3326e091d9e18d51eff3d66bdd0a00c 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());
     }