Returning a reference is incorrect if the specified pair was a
temporary -- Instead of that, use decltype() to deduce the correct
return type qualifiers. Fixes a crash in clCreateProgramWithBinary().
Reported-and-tested-by: "Dorrington, Albert" <albert.dorrington@lmco.com>
struct keys {
template<typename P>
- typename std::remove_reference<P>::type::first_type &
- operator()(P &&p) const {
- return p.first;
+ auto
+ operator()(P &&p) const -> decltype(std::get<0>(std::forward<P>(p))) {
+ return std::get<0>(std::forward<P>(p));
}
};
struct values {
template<typename P>
- typename std::remove_reference<P>::type::second_type &
- operator()(P &&p) const {
- return p.second;
+ auto
+ operator()(P &&p) const -> decltype(std::get<1>(std::forward<P>(p))) {
+ return std::get<1>(std::forward<P>(p));
}
};