1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <vector> 11// vector<bool> 12 13// explicit vector(size_type n); 14 15#include <vector> 16#include <cassert> 17 18#include "min_allocator.h" 19#include "test_allocator.h" 20 21template <class C> 22void 23test2(typename C::size_type n, typename C::allocator_type const& a = typename C::allocator_type ()) 24{ 25#if _LIBCPP_STD_VER > 11 26 C c(n, a); 27 assert(c.__invariants()); 28 assert(c.size() == n); 29 assert(c.get_allocator() == a); 30#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 31 for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i) 32 assert(*i == typename C::value_type()); 33#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 34#endif 35} 36 37template <class C> 38void 39test1(typename C::size_type n) 40{ 41 C c(n); 42 assert(c.__invariants()); 43 assert(c.size() == n); 44 assert(c.get_allocator() == typename C::allocator_type()); 45 for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i) 46 assert(*i == typename C::value_type()); 47} 48 49template <class C> 50void 51test(typename C::size_type n) 52{ 53 test1<C> ( n ); 54 test2<C> ( n ); 55} 56 57int main() 58{ 59 test<std::vector<bool> >(50); 60#if __cplusplus >= 201103L 61 test<std::vector<bool, min_allocator<bool>> >(50); 62 test2<std::vector<bool, test_allocator<bool>> >( 100, test_allocator<bool>(23)); 63#endif 64} 65