diff options
Diffstat (limited to 'include/forward_list')
-rw-r--r-- | include/forward_list | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/include/forward_list b/include/forward_list index 7b8204137201..571afdc925b0 100644 --- a/include/forward_list +++ b/include/forward_list @@ -134,6 +134,11 @@ public: void reverse() noexcept; }; + +template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> + forward_list(InputIterator, InputIterator, Allocator = Allocator()) + -> forward_list<typename iterator_traits<InputIterator>::value_type, Allocator>; // C++17 + template <class T, class Allocator> bool operator==(const forward_list<T, Allocator>& x, const forward_list<T, Allocator>& y); @@ -452,6 +457,10 @@ protected: typedef typename allocator_traits<__begin_node_allocator>::pointer __begin_node_pointer; + static_assert((!is_same<allocator_type, __node_allocator>::value), + "internal allocator type must differ from user-specified " + "type; otherwise overload resolution breaks"); + __compressed_pair<__begin_node, __node_allocator> __before_begin_; _LIBCPP_INLINE_VISIBILITY @@ -476,9 +485,11 @@ protected: _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) : __before_begin_(__begin_node()) {} _LIBCPP_INLINE_VISIBILITY - __forward_list_base(const allocator_type& __a) + explicit __forward_list_base(const allocator_type& __a) : __before_begin_(__begin_node(), __node_allocator(__a)) {} - + _LIBCPP_INLINE_VISIBILITY + explicit __forward_list_base(const __node_allocator& __a) + : __before_begin_(__begin_node(), __a) {} #ifndef _LIBCPP_CXX03_LANG public: _LIBCPP_INLINE_VISIBILITY @@ -845,6 +856,23 @@ private: __sort(__node_pointer __f, difference_type __sz, _Compare& __comp); }; + +#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES +template<class _InputIterator, + class _Alloc = typename std::allocator<typename iterator_traits<_InputIterator>::value_type>, + class = typename enable_if<__is_allocator<_Alloc>::value, void>::type + > +forward_list(_InputIterator, _InputIterator) + -> forward_list<typename iterator_traits<_InputIterator>::value_type, _Alloc>; + +template<class _InputIterator, + class _Alloc, + class = typename enable_if<__is_allocator<_Alloc>::value, void>::type + > +forward_list(_InputIterator, _InputIterator, _Alloc) + -> forward_list<typename iterator_traits<_InputIterator>::value_type, _Alloc>; +#endif + template <class _Tp, class _Alloc> inline forward_list<_Tp, _Alloc>::forward_list(const allocator_type& __a) @@ -932,12 +960,9 @@ forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l, template <class _Tp, class _Alloc> forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x) - : base(allocator_type( - __node_traits::select_on_container_copy_construction(__x.__alloc()) - ) - ) -{ - insert_after(cbefore_begin(), __x.begin(), __x.end()); + : base( + __node_traits::select_on_container_copy_construction(__x.__alloc())) { + insert_after(cbefore_begin(), __x.begin(), __x.end()); } template <class _Tp, class _Alloc> |