Merge branch 'do-not-require-property-valuetype-default-constructible' into 'master'
do not require Gaudi::Property::ValueType to be default constructible See merge request !271
-
This breaks LHCb compilation with clang:
In file included from /build/jenkins-build-new/workspace/nightly-builds/build/build/LHCB/LHCB_HEAD/Velo/VeloDAQ/src/VeloClusterFilter.cpp:4: In file included from /build/jenkins-build-new/workspace/nightly-builds/build/build/LHCB/LHCB_HEAD/Det/VeloDet/VeloDet/DeVelo.h:10: In file included from /build/jenkins-build-new/workspace/nightly-builds/build/build/LHCB/LHCB_HEAD/Det/VeloDet/VeloDet/DeVeloSensor.h:17: In file included from /build/jenkins-build-new/workspace/nightly-builds/build/build/LHCB/LHCB_HEAD/Det/DetDesc/DetDesc/DetectorElement.h:18: In file included from /build/jenkins-build-new/workspace/nightly-builds/build/build/GAUDI/GAUDI_master/InstallArea/x86_64-slc6-clang39-opt/include/GaudiKernel/CommonMessaging.h:11: In file included from /build/jenkins-build-new/workspace/nightly-builds/build/build/GAUDI/GAUDI_master/InstallArea/x86_64-slc6-clang39-opt/include/GaudiKernel/ISvcLocator.h:6: In file included from /build/jenkins-build-new/workspace/nightly-builds/build/build/GAUDI/GAUDI_master/InstallArea/x86_64-slc6-clang39-opt/include/GaudiKernel/ISvcManager.h:7: In file included from /build/jenkins-build-new/workspace/nightly-builds/build/build/GAUDI/GAUDI_master/InstallArea/x86_64-slc6-clang39-opt/include/GaudiKernel/TypeNameString.h:3: /build/jenkins-build-new/workspace/nightly-builds/build/build/GAUDI/GAUDI_master/InstallArea/x86_64-slc6-clang39-opt/include/GaudiKernel/Property.h:350:50: error: no type named 'type' in 'std::enable_if<false, void>'; 'enable_if' cannot be used to disable this declaration typename = typename std::enable_if<std::is_default_constructible<ValueType>::value>::type> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /build/jenkins-build-new/workspace/nightly-builds/build/build/LHCB/LHCB_HEAD/Velo/VeloDAQ/src/VeloClusterFilter.h:42:29: note: in instantiation of template class 'Gaudi::Property<VeloClusterFilter::filter_t, Gaudi::Details::Property::NullVerifier, Gaudi::Details::Property::UpdateHandler>' requested here Gaudi::Property<filter_t> m_filter{ this, "FilterOption", filter_t::criterion_t::ALL };
-
Interesting... Given that
filter_t
is defined asstruct filter_t final { enum class criterion_t { ALL = 0, LEFT, RIGHT, R, PHI, PU, OVERLAP }; criterion_t criterion; filter_t( criterion_t c = criterion_t::ALL ) : criterion(c) {} bool operator()(LHCb::VeloChannelID id) const; const std::string& toString() const; // add support for Gaudi::Property<filter_t> friend std::ostream& toStream(const filter_t& crit, std::ostream& os); friend StatusCode parse(filter_t& result, const std::string& input ); };
I would expect that it is default constructible. And if it isn't this should be classic SFINAE, i.e. 'Substitution Failure Is Not An Error' -- i.e. this template should just not be instantiated instead of giving an error...
If I try to reproduce it in a short example, clang 3.9.1 is happy, and confirms that
filter_t
is default constructible, see https://godbolt.org/g/kO4pGT So I'm open to suggestions... -
An example closer to this situation (using
std::enable_if
to pick an overload) also compiles with clang 3.9, see https://godbolt.org/g/aLQkCx Depending on the#if
clause (which flipsfilter_t
between being default constructible and not) it either returns 1 or 0... so in the example the overload resolution is happening as expected, and SFINAE does what I think it should be doing... -
-
I suspect this is the fix:
diff --git a/GaudiKernel/GaudiKernel/Property.h b/GaudiKernel/GaudiKernel/Property.h index 9f274c9..0e44610 100644 --- a/GaudiKernel/GaudiKernel/Property.h +++ b/GaudiKernel/GaudiKernel/Property.h @@ -347,7 +347,7 @@ namespace Gaudi /// @note the use std::enable_if is required to avoid ambiguities template <class OWNER, class T = ValueType, typename = typename std::enable_if<std::is_base_of<IProperty, OWNER>::value>::type, - typename = typename std::enable_if<std::is_default_constructible<ValueType>::value>::type> + typename = typename std::enable_if<std::is_default_constructible<T>::value>::type> inline Property( OWNER* owner, std::string name ) : Property( std::move( name ), ValueType{}, "" ) {
-
I agree, an I just added this fix to my MR !294 (merged) (61adab82)