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

Unified Diff: base/template_util.h

Issue 2944523002: Improving flat containers interface. (Closed)
Patch Set: Other platforms compilation 2. Created 3 years, 5 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 | « base/containers/flat_tree_unittest.cc ('k') | 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 e7e93f82331332781417c11b7eed82ae4e983bf7..0cf1477cf9a57b2e7326f5de40dae60f73bb4aa8 100644
--- a/base/template_util.h
+++ b/base/template_util.h
@@ -42,6 +42,19 @@ template <class T> struct is_non_const_reference<const T&> : std::false_type {};
namespace internal {
+template <typename...>
+struct make_void {
+ using type = void;
+};
+
+// A clone of C++17 std::void_t.
+// Unlike the original version, we need |make_void| as a helper struct to avoid
+// a C++14 defect.
+// ref: http://en.cppreference.com/w/cpp/types/void_t
+// ref: http://open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#1558
+template <typename... Ts>
+using void_t = typename make_void<Ts...>::type;
+
// Uses expression SFINAE to detect whether using operator<< would work.
template <typename T, typename = void>
struct SupportsOstreamOperator : std::false_type {};
@@ -96,6 +109,19 @@ template <class T>
using is_trivially_copyable = std::is_trivially_copyable<T>;
#endif
+// std::less<> from C++14.
+struct less {
+ template <typename T, typename U>
+ constexpr auto operator()(T&& lhs, U&& rhs) const
+ -> decltype(std::forward<T>(lhs) < std::forward<U>(rhs)) {
+ return std::forward<T>(lhs) < std::forward<U>(rhs);
+ }
+
+ // You can find more information about transparent comparisons here:
+ // http://en.cppreference.com/w/cpp/utility/functional/less_void
+ using is_transparent = int;
+};
+
} // namespace base
#undef CR_USE_FALLBACKS_FOR_GCC_WITH_LIBCXX
« no previous file with comments | « base/containers/flat_tree_unittest.cc ('k') | base/template_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698