Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Unified Diff: base/logging.h

Issue 2692853008: Use universal references in templated analysis passthrough functions. (Closed)
Patch Set: memory => utility for std::forward Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/logging.h
diff --git a/base/logging.h b/base/logging.h
index c0ebaf92bd3da3da67fa467cea0399542790debd..8a2cc66310b50ed1e0f0b07fc58ba82bc68b1584 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -298,22 +298,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)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698