From 2abfcd5606b3035624a76c71b862e344077d5caa Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Wed, 3 Jun 2015 16:15:55 +0000 Subject: Add 'is_always_equal' tests for scoped_allocator. Found that I had typed '||' where I meant '&&' in the code; fixed that, too llvm-svn: 238931 --- libcxx/include/scoped_allocator | 2 +- .../is_always_equal.pass.cpp | 75 ++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 libcxx/test/std/utilities/allocator.adaptor/allocator.adaptor.types/is_always_equal.pass.cpp (limited to 'libcxx') diff --git a/libcxx/include/scoped_allocator b/libcxx/include/scoped_allocator index 22e3a30847e..cd4987ad9bb 100644 --- a/libcxx/include/scoped_allocator +++ b/libcxx/include/scoped_allocator @@ -183,7 +183,7 @@ template 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; }; diff --git a/libcxx/test/std/utilities/allocator.adaptor/allocator.adaptor.types/is_always_equal.pass.cpp b/libcxx/test/std/utilities/allocator.adaptor/allocator.adaptor.types/is_always_equal.pass.cpp new file mode 100644 index 00000000000..e19e731f6cf --- /dev/null +++ b/libcxx/test/std/utilities/allocator.adaptor/allocator.adaptor.types/is_always_equal.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// typedef see below is_always_equal; + +#include +#include + +#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>::is_always_equal, std::false_type>::value + ), "" ); + + static_assert( (std::is_same< + std::allocator_traits>::is_always_equal, std::true_type>::value + ), "" ); + + // wrapping one allocator + static_assert( + (std::is_same< + std::scoped_allocator_adaptor>::is_always_equal, + std::allocator_traits>::is_always_equal + >::value), ""); + + // wrapping one allocator + static_assert( + (std::is_same< + std::scoped_allocator_adaptor>::is_always_equal, + std::allocator_traits>::is_always_equal + >::value), ""); + + // wrapping two allocators (check the values instead of the types) + static_assert(( + std::scoped_allocator_adaptor, A2>::is_always_equal::value == + ( std::allocator_traits>::is_always_equal::value && + std::allocator_traits>::is_always_equal::value) + ), ""); + + // wrapping two allocators (check the values instead of the types) + static_assert(( + std::scoped_allocator_adaptor, min_allocator>::is_always_equal::value == + ( std::allocator_traits>::is_always_equal::value && + std::allocator_traits>::is_always_equal::value) + ), ""); + + + // wrapping three allocators (check the values instead of the types) + static_assert(( + std::scoped_allocator_adaptor, A2, A3>::is_always_equal::value == + ( std::allocator_traits>::is_always_equal::value && + std::allocator_traits>::is_always_equal::value && + std::allocator_traits>::is_always_equal::value) + ), ""); + + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} -- cgit v1.2.3