[libcxx] r190251 - LWG Issue 2210 (Part #1): deque
Marshall Clow
mclow.lists at gmail.com
Sat Sep 7 09:16:19 PDT 2013
Author: marshall
Date: Sat Sep 7 11:16:19 2013
New Revision: 190251
URL: http://llvm.org/viewvc/llvm-project?rev=190251&view=rev
Log:
LWG Issue 2210 (Part #1): deque
Modified:
libcxx/trunk/include/deque
libcxx/trunk/test/containers/sequences/deque/deque.cons/size.pass.cpp
Modified: libcxx/trunk/include/deque
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/deque?rev=190251&r1=190250&r2=190251&view=diff
==============================================================================
--- libcxx/trunk/include/deque (original)
+++ libcxx/trunk/include/deque Sat Sep 7 11:16:19 2013
@@ -41,6 +41,7 @@ public:
deque() noexcept(is_nothrow_default_constructible<allocator_type>::value);
explicit deque(const allocator_type& a);
explicit deque(size_type n);
+ explicit deque(size_type n, const Allocator& a); // C++14
deque(size_type n, const value_type& v);
deque(size_type n, const value_type& v, const allocator_type& a);
template <class InputIterator>
@@ -1209,6 +1210,9 @@ public:
{}
_LIBCPP_INLINE_VISIBILITY deque(const allocator_type& __a) : __base(__a) {}
explicit deque(size_type __n);
+#if _LIBCPP_STD_VER > 11
+ explicit deque(size_type __n, const _Allocator& __a);
+#endif
deque(size_type __n, const value_type& __v);
deque(size_type __n, const value_type& __v, const allocator_type& __a);
template <class _InputIter>
@@ -1431,6 +1435,16 @@ deque<_Tp, _Allocator>::deque(size_type
__append(__n);
}
+#if _LIBCPP_STD_VER > 11
+template <class _Tp, class _Allocator>
+deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a)
+ : __base(__a)
+{
+ if (__n > 0)
+ __append(__n);
+}
+#endif
+
template <class _Tp, class _Allocator>
deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v)
{
Modified: libcxx/trunk/test/containers/sequences/deque/deque.cons/size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/deque/deque.cons/size.pass.cpp?rev=190251&r1=190250&r2=190251&view=diff
==============================================================================
--- libcxx/trunk/test/containers/sequences/deque/deque.cons/size.pass.cpp (original)
+++ libcxx/trunk/test/containers/sequences/deque/deque.cons/size.pass.cpp Sat Sep 7 11:16:19 2013
@@ -20,7 +20,29 @@
template <class T, class Allocator>
void
-test(unsigned n)
+test2(unsigned n)
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::deque<T, Allocator> C;
+ typedef typename C::const_iterator const_iterator;
+ assert(DefaultOnly::count == 0);
+ {
+ C d(n, Allocator());
+ assert(DefaultOnly::count == n);
+ assert(d.size() == n);
+ assert(distance(d.begin(), d.end()) == d.size());
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
+ assert(*i == T());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+ assert(DefaultOnly::count == 0);
+#endif
+}
+
+template <class T, class Allocator>
+void
+test1(unsigned n)
{
typedef std::deque<T, Allocator> C;
typedef typename C::const_iterator const_iterator;
@@ -38,6 +60,29 @@ test(unsigned n)
assert(DefaultOnly::count == 0);
}
+template <class T, class Allocator>
+void
+test3(unsigned n, Allocator const &alloc = Allocator())
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::deque<T, Allocator> C;
+ typedef typename C::const_iterator const_iterator;
+ {
+ C d(n, alloc);
+ assert(d.size() == n);
+ assert(d.get_allocator() == alloc);
+ }
+#endif
+}
+
+template <class T, class Allocator>
+void
+test(unsigned n)
+{
+ test1<T, Allocator> ( n );
+ test2<T, Allocator> ( n );
+}
+
int main()
{
test<DefaultOnly, std::allocator<DefaultOnly> >(0);
@@ -52,8 +97,17 @@ int main()
test<DefaultOnly, std::allocator<DefaultOnly> >(4095);
test<DefaultOnly, std::allocator<DefaultOnly> >(4096);
test<DefaultOnly, std::allocator<DefaultOnly> >(4097);
- test<DefaultOnly, stack_allocator<DefaultOnly, 4096> >(4095);
+
+ test1<DefaultOnly, stack_allocator<DefaultOnly, 4096> >(4095);
+
#if __cplusplus >= 201103L
test<DefaultOnly, min_allocator<DefaultOnly> >(4095);
#endif
+
+#if _LIBCPP_STD_VER > 11
+ test3<DefaultOnly, std::allocator<DefaultOnly>> (1023);
+ test3<int, std::allocator<int>>(1);
+ test3<int, min_allocator<int>> (3);
+#endif
+
}
More information about the cfe-commits
mailing list