[libcxx] r282126 - Add missing _v traits. is_bind_expression_v, is_placeholder_v and uses_allocator_v

Marshall Clow via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 21 17:23:15 PDT 2016


Author: marshall
Date: Wed Sep 21 19:23:15 2016
New Revision: 282126

URL: http://llvm.org/viewvc/llvm-project?rev=282126&view=rev
Log:
Add missing _v traits. is_bind_expression_v, is_placeholder_v and uses_allocator_v

Modified:
    libcxx/trunk/include/__functional_base
    libcxx/trunk/include/functional
    libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp
    libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp
    libcxx/trunk/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp

Modified: libcxx/trunk/include/__functional_base
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__functional_base?rev=282126&r1=282125&r2=282126&view=diff
==============================================================================
--- libcxx/trunk/include/__functional_base (original)
+++ libcxx/trunk/include/__functional_base Wed Sep 21 19:23:15 2016
@@ -625,6 +625,11 @@ struct _LIBCPP_TYPE_VIS_ONLY uses_alloca
 {
 };
 
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class _Alloc>
+constexpr size_t uses_allocator_v = uses_allocator<_Tp, _Alloc>::value;
+#endif
+
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 
 // allocator construction

Modified: libcxx/trunk/include/functional
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/functional?rev=282126&r1=282125&r2=282126&view=diff
==============================================================================
--- libcxx/trunk/include/functional (original)
+++ libcxx/trunk/include/functional Wed Sep 21 19:23:15 2016
@@ -212,6 +212,13 @@ template <class F> unspecified not_fn(F&
 template<class T> struct is_bind_expression;
 template<class T> struct is_placeholder;
 
+    // See C++14 20.9.9, Function object binders
+template <class T> constexpr bool is_bind_expression_v
+  = is_bind_expression<T>::value; // C++17
+template <class T> constexpr int is_placeholder_v
+  = is_placeholder<T>::value; // C++17
+
+
 template<class Fn, class... BoundArgs>
   unspecified bind(Fn&&, BoundArgs&&...);
 template<class R, class Fn, class... BoundArgs>
@@ -1970,10 +1977,20 @@ template<class _Tp> struct __is_bind_exp
 template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression
     : public __is_bind_expression<typename remove_cv<_Tp>::type> {};
 
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value;
+#endif
+
 template<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {};
 template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_placeholder
     : public __is_placeholder<typename remove_cv<_Tp>::type> {};
 
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+constexpr size_t is_placeholder_v = is_placeholder<_Tp>::value;
+#endif
+
 namespace placeholders
 {
 

Modified: libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp?rev=282126&r1=282125&r2=282126&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp Wed Sep 21 19:23:15 2016
@@ -14,12 +14,16 @@
 // template<class T> struct is_bind_expression
 
 #include <functional>
+#include "test_macros.h"
 
 template <bool Expected, class T>
 void
 test(const T&)
 {
     static_assert(std::is_bind_expression<T>::value == Expected, "");
+#if TEST_STD_VER > 14
+    static_assert(std::is_bind_expression_v<T> == Expected, "");
+#endif
 }
 
 struct C {};

Modified: libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp?rev=282126&r1=282125&r2=282126&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp Wed Sep 21 19:23:15 2016
@@ -12,12 +12,16 @@
 // struct is_placeholder
 
 #include <functional>
+#include "test_macros.h"
 
 template <int Expected, class T>
 void
 test(const T&)
 {
     static_assert(std::is_placeholder<T>::value == Expected, "");
+#if TEST_STD_VER > 14
+    static_assert(std::is_placeholder_v<T> == Expected, "");
+#endif
 }
 
 struct C {};

Modified: libcxx/trunk/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp?rev=282126&r1=282125&r2=282126&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp Wed Sep 21 19:23:15 2016
@@ -38,16 +38,38 @@ private:
   typedef int allocator_type;
 };
 
+template <bool Expected, class T, class A>
+void
+test()
+{
+    static_assert(std::uses_allocator<T, A>::value == Expected, "");
+#if TEST_STD_VER > 14
+    static_assert(std::uses_allocator_v<T, A> == Expected, "");
+#endif
+}
+
 int main()
 {
-    static_assert((!std::uses_allocator<int, std::allocator<int> >::value), "");
-    static_assert(( std::uses_allocator<std::vector<int>, std::allocator<int> >::value), "");
-    static_assert((!std::uses_allocator<A, std::allocator<int> >::value), "");
-    static_assert((!std::uses_allocator<B, std::allocator<int> >::value), "");
-    static_assert(( std::uses_allocator<B, double>::value), "");
-    static_assert((!std::uses_allocator<C, decltype(C::allocator_type)>::value), "");
-    static_assert((!std::uses_allocator<D, decltype(D::allocator_type)>::value), "");
+    test<false, int, std::allocator<int> >();
+    test<true, std::vector<int>, std::allocator<int> >();
+    test<false, A, std::allocator<int> >();
+    test<false, B, std::allocator<int> >();
+    test<true, B, double>();
+    test<false, C, decltype(C::allocator_type)>();
+    test<false, D, decltype(D::allocator_type)>();
 #if TEST_STD_VER >= 11
-    static_assert((!std::uses_allocator<E, int>::value), "");
+    test<false, E, int>();
 #endif
+
+
+//     static_assert((!std::uses_allocator<int, std::allocator<int> >::value), "");
+//     static_assert(( std::uses_allocator<std::vector<int>, std::allocator<int> >::value), "");
+//     static_assert((!std::uses_allocator<A, std::allocator<int> >::value), "");
+//     static_assert((!std::uses_allocator<B, std::allocator<int> >::value), "");
+//     static_assert(( std::uses_allocator<B, double>::value), "");
+//     static_assert((!std::uses_allocator<C, decltype(C::allocator_type)>::value), "");
+//     static_assert((!std::uses_allocator<D, decltype(D::allocator_type)>::value), "");
+// #if TEST_STD_VER >= 11
+//     static_assert((!std::uses_allocator<E, int>::value), "");
+// #endif
 }




More information about the cfe-commits mailing list