<div dir="ltr">Sorry to not reply to all. So FYI.<br><div><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Zeson Wu</b> <span dir="ltr"><<a href="mailto:westion717@gmail.com">westion717@gmail.com</a>></span><br>Date: 2018-03-08 10:32 GMT+08:00<br>Subject: Re: [cfe-dev] [libc++] Is libc++ compatible with previous c++ language standard implementation<br>To: alan snape <<a href="mailto:alansnape3058@gmail.com">alansnape3058@gmail.com</a>><br><br><br><div dir="ltr"><div>What I mean above for libc++ is the source/header of libc++ library.<br><br></div>I can not find the prototype of (1). I just find<br><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">#<span class="m_-8924835833352056804gmail-pl-k">if</span> _LIBCPP_STD_VER > 11
      
      
        <table class="m_-8924835833352056804gmail-highlight m_-8924835833352056804gmail-tab-size m_-8924835833352056804gmail-js-file-line-container"><tbody><tr><td id="m_-8924835833352056804gmail-LC493" class="m_-8924835833352056804gmail-blob-code m_-8924835833352056804gmail-blob-code-inner m_-8924835833352056804gmail-js-file-line">    <span class="m_-8924835833352056804gmail-pl-k">explicit</span> <span class="m_-8924835833352056804gmail-pl-en">vector</span>(size_type __n, <span class="m_-8924835833352056804gmail-pl-k">const</span> allocator_type& __a);</td>
      </tr>
      <tr>
        </tr></tbody></table><table class="m_-8924835833352056804gmail-highlight m_-8924835833352056804gmail-tab-size m_-8924835833352056804gmail-js-file-line-container"><tbody><tr><td id="m_-8924835833352056804gmail-LC494" class="m_-8924835833352056804gmail-blob-code m_-8924835833352056804gmail-blob-code-inner m_-8924835833352056804gmail-js-file-line">#<span class="m_-8924835833352056804gmail-pl-k">endif</span></td>
      </tr>
      <tr>
        </tr></tbody></table><table class="m_-8924835833352056804gmail-highlight m_-8924835833352056804gmail-tab-size m_-8924835833352056804gmail-js-file-line-container"><tbody><tr><td id="m_-8924835833352056804gmail-LC495" class="m_-8924835833352056804gmail-blob-code m_-8924835833352056804gmail-blob-code-inner m_-8924835833352056804gmail-js-file-line">    <span class="m_-8924835833352056804gmail-pl-en">vector</span>(size_type __n, const_reference __x);</td>
      </tr>
      <tr>
        </tr></tbody></table>    <span class="m_-8924835833352056804gmail-pl-en">vector</span>(size_type __n, const_reference __x, <span class="m_-8924835833352056804gmail-pl-k">const</span> allocator_type& __a);</blockquote><div><br></div><div>Is the implementation legal and to be suitable for all language level among 03, 11 and 14? But how to explain the case I showed before? The output of the case is different by gcc with option -std=c++11 and -std=c++03, but it's same by clang.<span class=""><br><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">#include <iostream><br>#include <vector><br><br>struct T<br>{<br>   bool flag;<br>   T() : flag(false) {}<br>   T(const T&) : flag(true) {}<br>};<br><br><br>int main()<br>{<br>   std::vector<T> test(1);<br>   bool is_cpp11 = !test[0].flag;<br><br>   std::cout << is_cpp11 << std::endl ;<br>}</blockquote><div> <br></div></span></div><br><br></div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">2018-03-08 10:09 GMT+08:00 alan snape <span dir="ltr"><<a href="mailto:alansnape3058@gmail.com" target="_blank">alansnape3058@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">As a template class, it is impossible to find the `std::vector` class in libc++. When writing a template class, all the code need during compile-time should be provided in the header file; and when compiling with a template class/function, the template parameter will be replaced with the concrete type/argument. As you can see, this is just a compile-time process rather than a link-time process, much less the libc++.<br><div class="gmail_extra"><br><div class="gmail_quote"><span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">explicit vector( size_type count, const T& value = T(), const Allocator& alloc = Allocator()); (until C++11) <b>(1)</b><br>explicit vector( size_type count );(since C++11) (until C++14) <b>(2)</b><br clear="all"><div><div><br></div><div>If I use vector<T> a(1), which one will be chosen with different c++ std command option, such as -std=c++03, -std=c++11? Actually, I can not find the (1) version in libc++ source.</div></div></div></blockquote></span><div>Just as what I mentioned above, the answer is it depends. If you compile your code under standard C++11, (2) will be used; if you use previous standard, (1) will be used. (Also, it depends on the argument you provided, but the header file will deal with it.)</div><span><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>In my option, both two functions should be implemented and guarded by related language level macro, but I can not find in libc++ source. So libc++ is not compatible with previous c++ language standard implementation?</div></div></blockquote></span><div>So, it is not weird to find nothing about that.</div></div></div></div>
</blockquote></div><br><br clear="all"><br></div></div><span class="HOEnZb"><font color="#888888">-- <br><div class="m_-8924835833352056804gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Zeson<br></div></div>
</font></span></div>
</div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Zeson<br></div></div>
</div></div>