summaryrefslogtreecommitdiffstats
path: root/libcxx/include
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2019-06-23 03:58:41 +0000
committerEric Fiselier <eric@efcs.ca>2019-06-23 03:58:41 +0000
commitde2b633a4a06c267d3361dd3c8a4d097156a18f8 (patch)
tree2bf32e101c418d13021756ad24b417365f6c0613 /libcxx/include
parent6281ccea02d355ab3e7ab1e3a765b753d688e6f5 (diff)
downloadbcm5719-llvm-de2b633a4a06c267d3361dd3c8a4d097156a18f8.tar.gz
bcm5719-llvm-de2b633a4a06c267d3361dd3c8a4d097156a18f8.zip
Add super fast _IsSame trait for internal use.
Clang provides __is_same that doesn't produce any instantiations and just returns a bool. It's a lot faster than using std::is_same I'll follow up with a patch to actually start using it. llvm-svn: 364148
Diffstat (limited to 'libcxx/include')
-rw-r--r--libcxx/include/type_traits31
1 files changed, 20 insertions, 11 deletions
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index 05405c96e56..def01d459cb 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -542,6 +542,26 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _
template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
#endif
+// is_same
+
+template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {};
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {};
+
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp, class _Up>
+_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_same_v
+ = is_same<_Tp, _Up>::value;
+#endif
+
+template <class _Tp, class _Up>
+using _IsSame = _BoolConstant<
+#ifdef __clang__
+ __is_same(_Tp, _Up)
+#else
+ _VSTD::is_same<_Tp, _Up>::value
+#endif
+>;
+
// addressof
#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
@@ -933,17 +953,6 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_class_v
= is_class<_Tp>::value;
#endif
-// is_same
-
-template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {};
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {};
-
-#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
-template <class _Tp, class _Up>
-_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_same_v
- = is_same<_Tp, _Up>::value;
-#endif
-
// is_function
namespace __libcpp_is_function_imp
OpenPOWER on IntegriCloud