@@ -2281,14 +2281,17 @@ class ResultOfMatcher {
2281
2281
class Impl : public MatcherInterface <T> {
2282
2282
using ResultType = decltype (CallableTraits<Callable>::template Invoke<T>(
2283
2283
std::declval<CallableStorageType>(), std::declval<T>()));
2284
+ using InnerType = std::conditional_t <
2285
+ std::is_lvalue_reference<ResultType>::value,
2286
+ const typename std::remove_reference<ResultType>::type&, ResultType>;
2284
2287
2285
2288
public:
2286
2289
template <typename M>
2287
2290
Impl (const std::string& result_description,
2288
2291
const CallableStorageType& callable, const M& matcher)
2289
2292
: result_description_(result_description),
2290
2293
callable_ (callable),
2291
- matcher_(MatcherCast<ResultType >(matcher)) {}
2294
+ matcher_(MatcherCast<InnerType >(matcher)) {}
2292
2295
2293
2296
void DescribeTo (::std::ostream* os) const override {
2294
2297
if (result_description_.empty ()) {
@@ -2318,7 +2321,7 @@ class ResultOfMatcher {
2318
2321
// takes a non-const reference as argument.
2319
2322
// Also, specifying template argument explicitly is needed because T could
2320
2323
// be a non-const reference (e.g. Matcher<Uncopyable&>).
2321
- ResultType result =
2324
+ InnerType result =
2322
2325
CallableTraits<Callable>::template Invoke<T>(callable_, obj);
2323
2326
return MatchPrintAndExplain (result, matcher_, listener);
2324
2327
}
@@ -2331,7 +2334,7 @@ class ResultOfMatcher {
2331
2334
// use stateful callables with ResultOf(), which doesn't guarantee
2332
2335
// how many times the callable will be invoked.
2333
2336
mutable CallableStorageType callable_;
2334
- const Matcher<ResultType > matcher_;
2337
+ const Matcher<InnerType > matcher_;
2335
2338
}; // class Impl
2336
2339
2337
2340
const std::string result_description_;
0 commit comments