summaryrefslogtreecommitdiff
path: root/runtime/base/stl_util.h
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2015-12-08 08:22:45 -0800
committer android-build-merger <android-build-merger@google.com> 2015-12-08 08:22:45 -0800
commit0b81f1715d6af9f98f982d6511e48973aa5a836a (patch)
tree06924f7e4b7f14db21fe41ec03a6b95eec29efeb /runtime/base/stl_util.h
parent641c83a8645ef9fd99dca06ec30bae8449b959c7 (diff)
parent2433d4e17c3006b8262a0d9421e201fc84777208 (diff)
Merge "Allow initializing runtime with parsed options." am: e0d25b156e
am: 2433d4e17c * commit '2433d4e17c3006b8262a0d9421e201fc84777208': Allow initializing runtime with parsed options.
Diffstat (limited to 'runtime/base/stl_util.h')
-rw-r--r--runtime/base/stl_util.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/runtime/base/stl_util.h b/runtime/base/stl_util.h
index 324ab218d2..ad03c319d9 100644
--- a/runtime/base/stl_util.h
+++ b/runtime/base/stl_util.h
@@ -156,6 +156,23 @@ struct CStringLess {
}
};
+// Use to suppress type deduction for a function argument.
+// See std::identity<> for more background:
+// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1856.html#20.2.2 - move/forward helpers
+//
+// e.g. "template <typename X> void bar(identity<X>::type foo);
+// bar(5); // compilation error
+// bar<int>(5); // ok
+// or "template <typename T> void foo(T* x, typename Identity<T*>::type y);
+// Base b;
+// Derived d;
+// foo(&b, &d); // Use implicit Derived* -> Base* conversion.
+// If T was deduced from both &b and &d, there would be a mismatch, i.e. deduction failure.
+template <typename T>
+struct Identity {
+ using type = T;
+};
+
} // namespace art
#endif // ART_RUNTIME_BASE_STL_UTIL_H_