clover: Fix clover::keys and ::values to deal with r-value references properly.

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>
This commit is contained in:
Francisco Jerez 2014-01-14 22:03:57 +01:00
parent 5662602ba0
commit bd62666224

View file

@ -289,17 +289,17 @@ namespace clover {
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));
}
};