diff options
Diffstat (limited to 'runtime/base/stl_util.h')
-rw-r--r-- | runtime/base/stl_util.h | 17 |
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_ |