<div dir="ltr">Hi Howard,<div><br></div><div style>This change breaks building LLVM with libc++, as follows:</div><div style>--</div><div>$ /Users/ddunbar/bin/xclang++ ... /Users/ddunbar/llvm/lib/Transforms/Utils/CodeExtractor.cpp ... -I ~/public/libcxx/include<br>
</div><div>/Users/ddunbar/llvm/lib/Transforms/Utils/CodeExtractor.cpp:752:28: error: </div><div>      no matching constructor for initialization of 'std::vector<BasicBlock *>'</div><div>  std::vector<BasicBlock*> Succs(succ_begin(codeReplacer),</div>
<div>                           ^     ~~~~~~~~~~~~~~~~~~~~~~~~~</div><div>/Users/ddunbar/public/libcxx/include/vector:523:5: note: candidate constructor not viable:</div><div>      no known conversion from 'succ_iterator' (aka 'SuccIterator<llvm::TerminatorInst *,</div>
<div>      llvm::BasicBlock>') to 'size_type' (aka 'unsigned long') for 1st argument</div><div>    vector(size_type __n, const_reference __x);</div><div>    ^</div><div>/Users/ddunbar/public/libcxx/include/vector:566:5: note: candidate constructor not viable:</div>
<div>      no known conversion from 'succ_iterator' (aka 'SuccIterator<llvm::TerminatorInst *,</div><div>      llvm::BasicBlock>') to 'const std::__1::vector<llvm::BasicBlock *,</div><div>      std::__1::allocator<llvm::BasicBlock *> >' for 1st argument</div>
<div>    vector(const vector& __x, const allocator_type& __a);</div><div>    ^</div><div>/Users/ddunbar/public/libcxx/include/vector:527:35: note: candidate template ignored:</div><div>      disabled by 'enable_if' [with _InputIterator =</div>
<div>      llvm::SuccIterator<llvm::TerminatorInst *, llvm::BasicBlock>]</div><div>               typename enable_if<__is_input_iterator  <_InputIterator>::value &&</div><div>                                  ^</div>
<div>/Users/ddunbar/public/libcxx/include/vector:541:35: note: candidate template ignored:</div><div>      disabled by 'enable_if' [with _ForwardIterator =</div><div>      llvm::SuccIterator<llvm::TerminatorInst *, llvm::BasicBlock>]</div>
<div>               typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&</div><div>                                  ^</div><div>/Users/ddunbar/public/libcxx/include/vector:533:9: note: candidate constructor template</div>
<div>      not viable: requires at least 3 arguments, but 2 were provided</div><div>        vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,</div><div>        ^</div><div>/Users/ddunbar/public/libcxx/include/vector:546:9: note: candidate constructor template</div>
<div>      not viable: requires at least 3 arguments, but 2 were provided</div><div>        vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_...</div><div>        ^</div><div>/Users/ddunbar/public/libcxx/include/vector:508:5: note: candidate constructor not viable:</div>
<div>      requires 0 arguments, but 2 were provided</div><div>    vector()</div><div>    ^</div><div>/Users/ddunbar/public/libcxx/include/vector:515:40: note: candidate constructor not</div><div>      viable: requires single argument '__a', but 2 arguments were provided</div>
<div>    _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)</div><div>                                       ^</div><div>/Users/ddunbar/public/libcxx/include/vector:522:14: note: candidate constructor not</div>
<div>      viable: requires single argument '__n', but 2 arguments were provided</div><div>    explicit vector(size_type __n);</div><div>             ^</div><div>/Users/ddunbar/public/libcxx/include/vector:524:5: note: candidate constructor not viable:</div>
<div>      requires 3 arguments, but 2 were provided</div><div>    vector(size_type __n, const_reference __x, const allocator_type& __a);</div><div>    ^</div><div>/Users/ddunbar/public/libcxx/include/vector:565:5: note: candidate constructor not viable:</div>
<div>      requires single argument '__x', but 2 arguments were provided</div><div>    vector(const vector& __x);</div><div>    ^</div><div>1 error generated.</div><div style>--</div><div style><br></div><div style>
I reverted it in r178116 for the time being, can you take a look?</div><div style><br></div><div style> - Daniel</div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Mar 26, 2013 at 2:40 PM, Howard Hinnant <span dir="ltr"><<a href="mailto:hhinnant@apple.com" target="_blank">hhinnant@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: hhinnant<br>
Date: Tue Mar 26 16:40:54 2013<br>
New Revision: 178075<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=178075&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=178075&view=rev</a><br>
Log:<br>
Tighten up the iterator requirements for the vector member templates.  This is especially important for the constructors so that is_constructible<vector<T>, I, I> gives the right answer when T can not be constructed from *I.  Test case included for this latter point.<br>

<br>
Modified:<br>
    libcxx/trunk/include/vector<br>
    libcxx/trunk/test/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp<br>
<br>
Modified: libcxx/trunk/include/vector<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/vector?rev=178075&r1=178074&r2=178075&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/vector?rev=178075&r1=178074&r2=178075&view=diff</a><br>

==============================================================================<br>
--- libcxx/trunk/include/vector (original)<br>
+++ libcxx/trunk/include/vector Tue Mar 26 16:40:54 2013<br>
@@ -526,17 +526,29 @@ public:<br>
     template <class _InputIterator><br>
         vector(_InputIterator __first, _InputIterator __last,<br>
                typename enable_if<__is_input_iterator  <_InputIterator>::value &&<br>
-                                 !__is_forward_iterator<_InputIterator>::value>::type* = 0);<br>
+                                 !__is_forward_iterator<_InputIterator>::value &&<br>
+                                 is_constructible<<br>
+                                    value_type,<br>
+                                    typename iterator_traits<_InputIterator>::reference>::value>::type* = 0);<br>
     template <class _InputIterator><br>
         vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,<br>
                typename enable_if<__is_input_iterator  <_InputIterator>::value &&<br>
-                                 !__is_forward_iterator<_InputIterator>::value>::type* = 0);<br>
+                                 !__is_forward_iterator<_InputIterator>::value &&<br>
+                                 is_constructible<<br>
+                                    value_type,<br>
+                                    typename iterator_traits<_InputIterator>::reference>::value>::type* = 0);<br>
     template <class _ForwardIterator><br>
         vector(_ForwardIterator __first, _ForwardIterator __last,<br>
-               typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type* = 0);<br>
+               typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&<br>
+                                 is_constructible<<br>
+                                    value_type,<br>
+                                    typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0);<br>
     template <class _ForwardIterator><br>
         vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,<br>
-               typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type* = 0);<br>
+               typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&<br>
+                                 is_constructible<<br>
+                                    value_type,<br>
+                                    typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0);<br>
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS<br>
     _LIBCPP_INLINE_VISIBILITY<br>
     vector(initializer_list<value_type> __il);<br>
@@ -577,14 +589,20 @@ public:<br>
         typename enable_if<br>
         <<br>
              __is_input_iterator  <_InputIterator>::value &&<br>
-            !__is_forward_iterator<_InputIterator>::value,<br>
+            !__is_forward_iterator<_InputIterator>::value &&<br>
+            is_constructible<<br>
+                 value_type,<br>
+                 typename iterator_traits<_InputIterator>::reference>::value,<br>
             void<br>
         >::type<br>
         assign(_InputIterator __first, _InputIterator __last);<br>
     template <class _ForwardIterator><br>
         typename enable_if<br>
         <<br>
-            __is_forward_iterator<_ForwardIterator>::value,<br>
+            __is_forward_iterator<_ForwardIterator>::value &&<br>
+            is_constructible<<br>
+                 value_type,<br>
+                 typename iterator_traits<_ForwardIterator>::reference>::value,<br>
             void<br>
         >::type<br>
         assign(_ForwardIterator __first, _ForwardIterator __last);<br>
@@ -700,14 +718,20 @@ public:<br>
         typename enable_if<br>
         <<br>
              __is_input_iterator  <_InputIterator>::value &&<br>
-            !__is_forward_iterator<_InputIterator>::value,<br>
+            !__is_forward_iterator<_InputIterator>::value &&<br>
+            is_constructible<<br>
+                 value_type,<br>
+                 typename iterator_traits<_InputIterator>::reference>::value,<br>
             iterator<br>
         >::type<br>
         insert(const_iterator __position, _InputIterator __first, _InputIterator __last);<br>
     template <class _ForwardIterator><br>
         typename enable_if<br>
         <<br>
-            __is_forward_iterator<_ForwardIterator>::value,<br>
+            __is_forward_iterator<_ForwardIterator>::value &&<br>
+            is_constructible<<br>
+                 value_type,<br>
+                 typename iterator_traits<_ForwardIterator>::reference>::value,<br>
             iterator<br>
         >::type<br>
         insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);<br>
@@ -1034,7 +1058,10 @@ template <class _Tp, class _Allocator><br>
 template <class _InputIterator><br>
 vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last,<br>
        typename enable_if<__is_input_iterator  <_InputIterator>::value &&<br>
-                         !__is_forward_iterator<_InputIterator>::value>::type*)<br>
+                         !__is_forward_iterator<_InputIterator>::value &&<br>
+                         is_constructible<<br>
+                            value_type,<br>
+                            typename iterator_traits<_InputIterator>::reference>::value>::type*)<br>
 {<br>
 #if _LIBCPP_DEBUG_LEVEL >= 2<br>
     __get_db()->__insert_c(this);<br>
@@ -1047,7 +1074,10 @@ template <class _Tp, class _Allocator><br>
 template <class _InputIterator><br>
 vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,<br>
        typename enable_if<__is_input_iterator  <_InputIterator>::value &&<br>
-                         !__is_forward_iterator<_InputIterator>::value>::type*)<br>
+                         !__is_forward_iterator<_InputIterator>::value &&<br>
+                         is_constructible<<br>
+                            value_type,<br>
+                            typename iterator_traits<_InputIterator>::reference>::value>::type*)<br>
     : __base(__a)<br>
 {<br>
 #if _LIBCPP_DEBUG_LEVEL >= 2<br>
@@ -1060,7 +1090,10 @@ vector<_Tp, _Allocator>::vector(_InputIt<br>
 template <class _Tp, class _Allocator><br>
 template <class _ForwardIterator><br>
 vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last,<br>
-                                typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*)<br>
+                                typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&<br>
+                                is_constructible<<br>
+                                   value_type,<br>
+                                   typename iterator_traits<_ForwardIterator>::reference>::value>::type*)<br>
 {<br>
 #if _LIBCPP_DEBUG_LEVEL >= 2<br>
     __get_db()->__insert_c(this);<br>
@@ -1076,7 +1109,10 @@ vector<_Tp, _Allocator>::vector(_Forward<br>
 template <class _Tp, class _Allocator><br>
 template <class _ForwardIterator><br>
 vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,<br>
-                                typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*)<br>
+                                typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&<br>
+                                is_constructible<<br>
+                                   value_type,<br>
+                                   typename iterator_traits<_ForwardIterator>::reference>::value>::type*)<br>
     : __base(__a)<br>
 {<br>
 #if _LIBCPP_DEBUG_LEVEL >= 2<br>
@@ -1258,7 +1294,10 @@ template <class _InputIterator><br>
 typename enable_if<br>
 <<br>
      __is_input_iterator  <_InputIterator>::value &&<br>
-    !__is_forward_iterator<_InputIterator>::value,<br>
+    !__is_forward_iterator<_InputIterator>::value &&<br>
+    is_constructible<<br>
+       _Tp,<br>
+       typename iterator_traits<_InputIterator>::reference>::value,<br>
     void<br>
 >::type<br>
 vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last)<br>
@@ -1272,7 +1311,10 @@ template <class _Tp, class _Allocator><br>
 template <class _ForwardIterator><br>
 typename enable_if<br>
 <<br>
-    __is_forward_iterator<_ForwardIterator>::value,<br>
+    __is_forward_iterator<_ForwardIterator>::value &&<br>
+    is_constructible<<br>
+       _Tp,<br>
+       typename iterator_traits<_ForwardIterator>::reference>::value,<br>
     void<br>
 >::type<br>
 vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)<br>
@@ -1753,7 +1795,10 @@ template <class _InputIterator><br>
 typename enable_if<br>
 <<br>
      __is_input_iterator  <_InputIterator>::value &&<br>
-    !__is_forward_iterator<_InputIterator>::value,<br>
+    !__is_forward_iterator<_InputIterator>::value &&<br>
+    is_constructible<<br>
+       _Tp,<br>
+       typename iterator_traits<_InputIterator>::reference>::value,<br>
     typename vector<_Tp, _Allocator>::iterator<br>
 >::type<br>
 vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)<br>
@@ -1805,7 +1850,10 @@ template <class _Tp, class _Allocator><br>
 template <class _ForwardIterator><br>
 typename enable_if<br>
 <<br>
-    __is_forward_iterator<_ForwardIterator>::value,<br>
+    __is_forward_iterator<_ForwardIterator>::value &&<br>
+    is_constructible<<br>
+       _Tp,<br>
+       typename iterator_traits<_ForwardIterator>::reference>::value,<br>
     typename vector<_Tp, _Allocator>::iterator<br>
 >::type<br>
 vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)<br>
<br>
Modified: libcxx/trunk/test/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp?rev=178075&r1=178074&r2=178075&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp?rev=178075&r1=178074&r2=178075&view=diff</a><br>

==============================================================================<br>
--- libcxx/trunk/test/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp (original)<br>
+++ libcxx/trunk/test/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp Tue Mar 26 16:40:54 2013<br>
@@ -28,6 +28,10 @@ test(Iterator first, Iterator last)<br>
         assert(*i == *first);<br>
 }<br>
<br>
+struct X<br>
+{<br>
+};<br>
+<br>
 int main()<br>
 {<br>
     int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};<br>
@@ -43,4 +47,7 @@ int main()<br>
     test<std::vector<int, stack_allocator<int, 18> > >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));<br>
     test<std::vector<int, stack_allocator<int, 18> > >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));<br>
     test<std::vector<int, stack_allocator<int, 18> > >(a, an);<br>
+<br>
+    X x[2];<br>
+    static_assert(!(std::is_constructible<std::vector<int>, X*, X*>::value), "");<br>
 }<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>