Skip to content
Snippets Groups Projects
Commit 5b1679c6 authored by scott snyder's avatar scott snyder Committed by scott snyder
Browse files

Fix deduction of property return values.

Fixes gcc8 compilation error with

prop["foo"]

where prop is a Property<std::map<std::string, std::string> >.

One gets an error like this (trimmed for brevity):

Control/AthenaExamples/AthExHelloWorld/src/HelloAlg.cxx: In constructor 'HelloAlg::HelloAlg(const string&, ISvcLocator*)':
Control/AthenaExamples/AthExHelloWorld/src/HelloAlg.cxx:26:11: error: no match for 'operator[]' (operand types are 'Gaudi::Property<std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > >' and 'const char [8]')
   m_myDict["Bonjour"]      = "Guten Tag";
           ^
In file included from /home/sss/atlas/extern/Gaudi/current/GaudiKernel/GaudiKernel/GaudiHandle.h:7,
                 from /home/sss/atlas/extern/Gaudi/current/GaudiKernel/GaudiKernel/ToolHandle.h:5,
                 from Control/AthenaExamples/AthExHelloWorld/src/HelloAlg.h:10,
                 from Control/AthenaExamples/AthExHelloWorld/src/HelloAlg.cxx:9:
/home/sss/atlas/extern/Gaudi/current/GaudiKernel/GaudiKernel/Property.h:544:49: note: candidate: 'template<class ARG, class T> decltype (declval<T>()[ARG{}]) Gaudi::Property<TYPE, VERIFIER, HANDLERS>::operator[](const ARG&) [with ARG = ARG; T = T; TYPE = std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >; VERIFIER = Gaudi::Details::Property::NullVerifier; HANDLERS = Gaudi::Details::Property::UpdateHandler]'
     inline decltype( std::declval<T>()[ARG{}] ) operator[]( const ARG& arg )
                                                 ^~~~~~~~
/home/sss/atlas/extern/Gaudi/current/GaudiKernel/GaudiKernel/Property.h:544:49: note:   template argument deduction/substitution failed:
/home/sss/atlas/extern/Gaudi/current/GaudiKernel/GaudiKernel/Property.h: In substitution of 'template<class ARG, class T> decltype (declval<T>()[ARG{}]) Gaudi::Property<std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > >::operator[]<ARG, T>(const ARG&) [with ARG = char [8]; T = std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >]':
Control/AthenaExamples/AthExHelloWorld/src/HelloAlg.cxx:26:21:   required from here
/home/sss/atlas/extern/Gaudi/current/GaudiKernel/GaudiKernel/Property.h:544:39: error: taking address of temporary array
     inline decltype( std::declval<T>()[ARG{}] ) operator[]( const ARG& arg )
                      ~~~~~~~~~~~~~~~~~^


Easiest fix seems to be to use decltype(auto) for the return types.
parent cb38e5ac
No related branches found
No related tags found
1 merge request!634Fix deduction of property return values.
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment