Author: marshall
Date: Wed Jun  3 11:15:55 2015
New Revision: 238931

URL: http://llvm.org/viewvc/llvm-project?rev=238931&view=rev
Log:
Add 'is_always_equal' tests for scoped_allocator. Found that I had typed '||' 
where I meant '&&' in the code; fixed that, too

Added:
    
libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/is_always_equal.pass.cpp
Modified:
    libcxx/trunk/include/scoped_allocator

Modified: libcxx/trunk/include/scoped_allocator
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/scoped_allocator?rev=238931&r1=238930&r2=238931&view=diff
==============================================================================
--- libcxx/trunk/include/scoped_allocator (original)
+++ libcxx/trunk/include/scoped_allocator Wed Jun  3 11:15:55 2015
@@ -183,7 +183,7 @@ template <class _A0, class ..._Allocs>
 struct __get_is_always_equal<_A0, _Allocs...>
 {
     static const bool value =
-        allocator_traits<_A0>::is_always_equal::value ||
+        allocator_traits<_A0>::is_always_equal::value &&
         __get_is_always_equal<_Allocs...>::value;
 };
 

Added: 
libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/is_always_equal.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/is_always_equal.pass.cpp?rev=238931&view=auto
==============================================================================
--- 
libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/is_always_equal.pass.cpp
 (added)
+++ 
libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.types/is_always_equal.pass.cpp
 Wed Jun  3 11:15:55 2015
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// typedef see below is_always_equal;
+
+#include <scoped_allocator>
+#include <type_traits>
+
+#include "allocators.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    // sanity checks
+    static_assert( (std::is_same<
+               std::allocator_traits<A1<int>>::is_always_equal, 
std::false_type>::value
+               ), "" );
+
+    static_assert( (std::is_same<
+               std::allocator_traits<min_allocator<int>>::is_always_equal, 
std::true_type>::value
+               ), "" );
+    
+    // wrapping one allocator
+    static_assert(
+        (std::is_same<
+            std::scoped_allocator_adaptor<A1<int>>::is_always_equal,
+            std::allocator_traits<A1<int>>::is_always_equal
+        >::value), "");
+
+    // wrapping one allocator
+    static_assert(
+        (std::is_same<
+            std::scoped_allocator_adaptor<min_allocator<int>>::is_always_equal,
+            std::allocator_traits<min_allocator<int>>::is_always_equal
+        >::value), "");
+
+    // wrapping two allocators (check the values instead of the types)
+    static_assert((
+            std::scoped_allocator_adaptor<A1<int>, 
A2<int>>::is_always_equal::value ==
+            ( std::allocator_traits<A1<int>>::is_always_equal::value &&
+              std::allocator_traits<A2<int>>::is_always_equal::value)    
+        ), "");
+
+    // wrapping two allocators (check the values instead of the types)
+    static_assert((
+            std::scoped_allocator_adaptor<A1<int>, 
min_allocator<int>>::is_always_equal::value ==
+            ( std::allocator_traits<A1<int>>::is_always_equal::value &&
+              
std::allocator_traits<min_allocator<int>>::is_always_equal::value)    
+        ), "");
+
+
+    // wrapping three allocators (check the values instead of the types)
+    static_assert((
+            std::scoped_allocator_adaptor<A1<int>, A2<int>, 
A3<int>>::is_always_equal::value ==
+            ( std::allocator_traits<A1<int>>::is_always_equal::value &&
+              std::allocator_traits<A2<int>>::is_always_equal::value &&    
+              std::allocator_traits<A3<int>>::is_always_equal::value)    
+        ), "");
+
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to