Chromium Code Reviews| Index: base/logging.h |
| diff --git a/base/logging.h b/base/logging.h |
| index c0ebaf92bd3da3da67fa467cea0399542790debd..2ce81e00e4d532d4ebdcbd5c3a4666fd069729b7 100644 |
| --- a/base/logging.h |
| +++ b/base/logging.h |
| @@ -9,6 +9,7 @@ |
| #include <cassert> |
| #include <cstring> |
| +#include <memory> |
|
danakj
2017/02/14 22:39:31
forward is in <utility> tho
Kevin M
2017/02/14 22:41:01
Done.
|
| #include <sstream> |
| #include <string> |
| #include <type_traits> |
| @@ -298,22 +299,26 @@ BASE_EXPORT LogMessageHandlerFunction GetLogMessageHandler(); |
| inline void AnalyzerNoReturn() __attribute__((analyzer_noreturn)) {} |
| +// |arg| is a universal reference for compatibility with lvalue and rvalue |
| +// arguments. |
| template <typename TVal> |
| -inline constexpr TVal AnalysisAssumeTrue(TVal arg) { |
| +inline constexpr TVal&& AnalysisAssumeTrue(TVal&& arg) { |
| if (!arg) { |
| AnalyzerNoReturn(); |
| } |
| - return arg; |
| + return std::forward<TVal>(arg); |
| } |
| #define ANALYZER_ASSUME_TRUE(val) ::logging::AnalysisAssumeTrue(val) |
| #elif defined(_PREFAST_) && defined(OS_WIN) |
| +// |arg| is a universal reference for compatibility with lvalue and rvalue |
| +// arguments. |
| template <typename TVal> |
| -inline constexpr TVal AnalysisAssumeTrue(TVal arg) { |
| +inline constexpr TVal&& AnalysisAssumeTrue(TVal&& arg) { |
| __analysis_assume(!!arg); |
| - return arg; |
| + return std::forward<TVal>(arg); |
| } |
| #define ANALYZER_ASSUME_TRUE(val) ::logging::AnalysisAssumeTrue(val) |