Implement deduction guides for vector

llvm-svn: 332901
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: df8f75479278d5ce16eede342ceb5ba2fd71460b
diff --git a/include/vector b/include/vector
index 54b1e88..8fad9ec 100644
--- a/include/vector
+++ b/include/vector
@@ -244,6 +244,10 @@
     bool __invariants() const;
 };
 
+template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
+   vector(InputIterator, InputIterator, Allocator = Allocator())
+   -> vector<typename iterator_traits<InputIterator>::value_type, Allocator>;
+
 template <class Allocator> struct hash<std::vector<bool, Allocator>>;
 
 template <class T, class Allocator> bool operator==(const vector<T,Allocator>& x, const vector<T,Allocator>& y);
@@ -316,13 +320,14 @@
 class __vector_base
     : protected __vector_base_common<true>
 {
-protected:
-    typedef _Tp                                      value_type;
+public:
     typedef _Allocator                               allocator_type;
     typedef allocator_traits<allocator_type>         __alloc_traits;
+    typedef typename __alloc_traits::size_type       size_type;
+protected:
+    typedef _Tp                                      value_type;
     typedef value_type&                              reference;
     typedef const value_type&                        const_reference;
-    typedef typename __alloc_traits::size_type       size_type;
     typedef typename __alloc_traits::difference_type difference_type;
     typedef typename __alloc_traits::pointer         pointer;
     typedef typename __alloc_traits::const_pointer   const_pointer;
@@ -492,8 +497,8 @@
 #if _LIBCPP_STD_VER > 11
     explicit vector(size_type __n, const allocator_type& __a);
 #endif
-    vector(size_type __n, const_reference __x);
-    vector(size_type __n, const_reference __x, const allocator_type& __a);
+    vector(size_type __n, const value_type& __x);
+    vector(size_type __n, const value_type& __x, const allocator_type& __a);
     template <class _InputIterator>
         vector(_InputIterator __first,
                typename enable_if<__is_input_iterator  <_InputIterator>::value &&
@@ -890,6 +895,22 @@
 
 };
 
+#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
+         >
+vector(_InputIterator, _InputIterator)
+  -> vector<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
+
+template<class _InputIterator,
+         class _Alloc,
+         class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
+         >
+vector(_InputIterator, _InputIterator, _Alloc)
+  -> vector<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
+#endif
+
 template <class _Tp, class _Allocator>
 void
 vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v)
@@ -1099,7 +1120,7 @@
 #endif
 
 template <class _Tp, class _Allocator>
-vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x)
+vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)
 {
 #if _LIBCPP_DEBUG_LEVEL >= 2
     __get_db()->__insert_c(this);
@@ -1112,7 +1133,7 @@
 }
 
 template <class _Tp, class _Allocator>
-vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x, const allocator_type& __a)
+vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)
     : __base(__a)
 {
 #if _LIBCPP_DEBUG_LEVEL >= 2