Allow ADL lookup of parse and toStream
Currently, if one introduces a Gaudi::Property<T>
, then there must be a corresponding StatusCode Gaudi::Parsers::parse(T&,const std::string&)
in the namespace Gaudi::Parsers
and a corresponding void Gaudi::Utils::toStream(const T&, std::stream&)
in the namespace Gaudi::Utils
.
This patch explicitly enables ADL lookup (with a fall-back to Gaudi::Parser::parse
and Gaudi::Utils::toStream
) so that it is sufficient to either define parse
and toStream
in the namespace in which T
is defined, or add them as friend
functions to T
.
Merge request reports
Activity
Mentioned in merge request lhcb/LHCb!458 (merged)
Mentioned in merge request lhcb/Gaudi!96 (merged)
Mentioned in commit lhcb/Gaudi@aeed153c
Mentioned in merge request lhcb/LHCb!466 (merged)
It is actually a bigger deal than one would suspect -- injecting symbols in Gaudi::Parse and Gaudi::Utils seems to be very dependent on the order of things. It seems that in complex cases you must forward declare prior to any Gaudi include, and define downstream, after including some relevant Gaudi headers. By using ADL this problem disappears, and makes things a lot easier...
If you take a look at HltConfigSvc.h and HltConfigSvc.cpp, you will see an extremely early forward declaration in the header file and a very late definition in the .cpp file -- and getting this right was a matter of a lot of trial and error. And with the proposed change here, the name lookup is much easier. Note that this matches (not by coincidence) the Standard Library usage of eg.
swap
,begin
,end
andoperator<<(std::ostream&, T)
. So no, it's not just cleanup, it simplifies actual problems and it is more than just a convention and yes, it also looks cleaner.Reassigned to @hegner
Validation started with lhcb-gaudi-merge#87
Mentioned in commit 291ba412