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

Unified Diff: base/template_util.h

Issue 6537001: Fix is_convertible for windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Silly Type conversion warning. Created 9 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 | base/template_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/template_util.h
diff --git a/base/template_util.h b/base/template_util.h
index 0408fc67a6e45a76664d0400126f139dbffab061..e48af9183b5a5e3255f169eb6ed31b7d6c0885e1 100644
--- a/base/template_util.h
+++ b/base/template_util.h
@@ -47,8 +47,6 @@ struct NoType {
YesType dummy[2];
};
-#if !defined(OS_WIN)
-
// This class is an implementation detail for is_convertible, and you
// don't need to know how it works to use is_convertible. For those
// who care: we declare two different functions, one whose argument is
@@ -58,15 +56,17 @@ struct NoType {
// had called it with an argument of type From. See Alexandrescu's
// _Modern C++ Design_ for more details on this sort of trick.
-template <typename From, typename To>
struct ConvertHelper {
+ template <typename To>
static YesType Test(To);
+
+ template <typename To>
static NoType Test(...);
+
+ template <typename From>
static From Create();
};
-#endif // !defined(OS_WIN)
-
// Used to determine if a type is a struct/union/class. Inspired by Boost's
// is_class type_trait implementation.
struct IsClassHelper {
@@ -79,19 +79,18 @@ struct IsClassHelper {
} // namespace internal
-#if !defined(OS_WIN)
-
// Inherits from true_type if From is convertible to To, false_type otherwise.
+//
+// Note that if the type is convertible, this will be a true_type REGARDLESS
+// of whether or not the conversion would emit a warning.
template <typename From, typename To>
struct is_convertible
: integral_constant<bool,
- sizeof(internal::ConvertHelper<From, To>::Test(
- internal::ConvertHelper<From, To>::Create()))
- == sizeof(internal::YesType)> {
+ sizeof(internal::ConvertHelper::Test<To>(
+ internal::ConvertHelper::Create<From>())) ==
+ sizeof(internal::YesType)> {
};
-#endif // !defined(OS_WIN)
-
template <typename T>
struct is_class
: integral_constant<bool,
« no previous file with comments | « no previous file | base/template_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698