LWG Issue 2210 (Part #2 & #3): list and forward_list
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@190279 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/forward_list b/include/forward_list
index a524f2c..2fbcdbe 100644
--- a/include/forward_list
+++ b/include/forward_list
@@ -38,6 +38,7 @@
noexcept(is_nothrow_default_constructible<allocator_type>::value);
explicit forward_list(const allocator_type& a);
explicit forward_list(size_type n);
+ explicit forward_list(size_type n, const Allocator& a); // C++14
forward_list(size_type n, const value_type& v);
forward_list(size_type n, const value_type& v, const allocator_type& a);
template <class InputIterator>
@@ -571,6 +572,9 @@
{} // = default;
explicit forward_list(const allocator_type& __a);
explicit forward_list(size_type __n);
+#if _LIBCPP_STD_VER > 11
+ explicit forward_list(size_type __n, const allocator_type& __a);
+#endif
forward_list(size_type __n, const value_type& __v);
forward_list(size_type __n, const value_type& __v, const allocator_type& __a);
template <class _InputIterator>
@@ -794,6 +798,28 @@
}
}
+#if _LIBCPP_STD_VER > 11
+template <class _Tp, class _Alloc>
+forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __a)
+ : base ( __a )
+{
+ if (__n > 0)
+ {
+ __node_allocator& __a = base::__alloc();
+ typedef __allocator_destructor<__node_allocator> _Dp;
+ unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1));
+ for (__node_pointer __p = base::__before_begin(); __n > 0; --__n,
+ __p = __p->__next_)
+ {
+ __h.reset(__node_traits::allocate(__a, 1));
+ __node_traits::construct(__a, _VSTD::addressof(__h->__value_));
+ __h->__next_ = nullptr;
+ __p->__next_ = __h.release();
+ }
+ }
+}
+#endif
+
template <class _Tp, class _Alloc>
forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v)
{