std::make_pair
has changed between c++03 and c++11.
In c++11, it accepts parameters by forwarding-references rather than by value. This means that by specifying its type template arguments explicitly you end up with the following instantiation:
std::make_pair<std::string , boost::shared_ptr<GPIOPin> >
(std::string&&, boost::shared_ptr<GPIOPin>&&);
expecting rvalue references, which cannot bind to lvalues.
You should not specify type template arguments of std::make_pair
explicitly. Instead, you should let the compiler deduce them on its own:
std::make_pair(p_pinNumber, pin)
Additionally, since c++11, when using std::map
, you can construct the pair in-place:
m_pinsInUse.emplace(p_pinNumber, pin);
In c++17 you can utilize class template argument deduction, and construct std::pair
without specifying class template arguments:
std::pair(p_pinNumber, pin)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…