<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 2017-Jun-18, at 10:46, Duncan P. N. Exon Smith <<a href="mailto:dexonsmith@apple.com" class="">dexonsmith@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><div class=""><br class="Apple-interchange-newline">On 2017-Jun-16, at 05:58, Duncan Exon Smith <<a href="mailto:dexonsmith@apple.com" class="">dexonsmith@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class="Apple-interchange-newline">On Jun 15, 2017, at 22:22, Eric Fiselier <<a href="mailto:eric@efcs.ca" class="">eric@efcs.ca</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Jun 15, 2017 at 11:00 PM, Duncan P. N. Exon Smith<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:dexonsmith@apple.com" target="_blank" class="">dexonsmith@apple.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class="" style="word-wrap: break-word;">Your suggestion is essentially to replace experimental/string_view with something like:<div class=""><br class=""></div><div class="">    namespace std { inline namespace __1 { namespace experimental {</div><div class="">      template <class CharT></div><div class="">      using basic_string_view = _VSTD::basic_string_view;</div><div class="">    }}}</div><div class=""><br class=""></div><div class="">That breaks:</div><div class="">1. User compiles 1.cpp with older toolchain.  1.cpp implements foo(std::experimental::string_<wbr class="">view).</div><div class="">2. User compiles 2.cpp with newer toolchain.  2.cpp calls foo(std::experimental::string_<wbr class="">view).</div><div class="">3. User links 1.o with 2.o.</div><div class=""><br class=""></div><div class="">I'm not sure if this matters.</div></div></blockquote><div class=""><br class=""></div><div class="">It can't matter. <experimental/foo> are allowed to break both their API and ABI as needed.</div><div class=""><br class=""></div><div class="">Also I was suggesting </div><div class=""><br class=""></div><div class="">   namespace std { namespace experimental {</div><div class="">     using std::basic_string_view;</div><div class="">     using std::string_view;</div><div class="">  }}</div><div class=""> </div><div class="">This approach will break code that expects experimental::string_view and std::string_view are different types:</div><div class="">Example:</div><div class=""><br class=""></div><div class="">  void foo(std::string_view);</div><div class="">  void foo(std::experimental::string_view);</div><div class="">  foo(std::string_view{}); // ambiguous</div></div></div></div></div></blockquote></div></blockquote><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">FTR, it also breaks code that relies on string_view::clear(), which disappeared.</div></div></blockquote><div><br class=""></div><div>More importantly, it breaks code that relies on string_view::to_string().  This one matters, since a "true" std::experimental::string_view wouldn't have the implicit conversions.</div><br class=""><blockquote type="cite" class=""><div class=""><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class="" style="word-wrap: break-word;"><div class=""><div class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Jun 15, 2017, at 21:55, Eric Fiselier <<a href="mailto:eric@efcs.ca" target="_blank" class="">eric@efcs.ca</a>> wrote:</div><br class="m_5535665134301237518Apple-interchange-newline"><div class=""><div dir="ltr" class="">I would also want to do serious performance analysis on this patch. Does removing the string_view overloads cause less optimal overloads to be chosen? Perhaps allocating ones?<div class="">That would be really unfortunate, and I'm not sure that's in the best interest of our users at large.</div></div></div></blockquote><div class=""><br class=""></div></span><div class="">Less optimal compared to what?  C++17 code?</div></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">Not sure yet, I'm trying to figure out what types the `const Tp&` overloads</div><div class="">are attempting to soak up. Is it only string_view? </div></div></div></div></div></blockquote><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">The type trait restricts it to things convertible to string_view that are not const char *.</div></blockquote><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">I had a bit of a look at experimental/filesystem, and it relies pretty heavily on the string/string_view conversions.  I still feel like this approach might be "the right one", but perhaps it's not worth it.</div><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class="" style="word-wrap: break-word;"><div class=""><div class=""><div class=""><div class=""><div class="h5"><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">/Eric</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Jun 15, 2017 at 10:51 PM, Duncan P. N. Exon Smith<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:dexonsmith@apple.com" target="_blank" class="">dexonsmith@apple.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class="" style="word-wrap: break-word;"><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Jun 15, 2017, at 19:42, Eric Fiselier <<a href="mailto:eric@efcs.ca" target="_blank" class="">eric@efcs.ca</a>> wrote:</div><br class="m_5535665134301237518m_3829869060949612838Apple-interchange-newline"><div class=""><br class="m_5535665134301237518m_3829869060949612838Apple-interchange-newline"><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">On Thu, Jun 15, 2017 at 8:38 PM, Duncan P. N. Exon Smith<span class="m_5535665134301237518m_3829869060949612838Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:dexonsmith@apple.com" target="_blank" class="">dexonsmith@apple.com</a>></span><span class="m_5535665134301237518m_3829869060949612838Apple-converted-space"> </span>w<wbr class="">rote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div class="" style="word-wrap: break-word;">I just started working on a patch to add #if guards, and the first interesting thing I found was the basic_string constructor:<div class=""><br class=""></div><div class=""><div class=""></div><blockquote type="cite" class=""><span class=""><div class="">template <class _CharT, class _Traits, class _Allocator></div></span><div class="">template <class _Tp></div><div class="">basic_string<_CharT, _Traits, _Allocator>::basic_string(</div><div class="">             const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a,</div><div class=""><span class="m_5535665134301237518m_3829869060949612838m_8776782733827039247Apple-tab-span" style="white-space: pre-wrap;">                       </span><span class="m_5535665134301237518m_3829869060949612838Apple-converted-space"> </span>typename enable_if<__can_be_converted_t<wbr class="">o_string_view<_CharT, _Traits, _Tp>::value, void>::type *)</div><div class="">   <span class="m_5535665134301237518m_3829869060949612838Apple-converted-space"> </span>: __r_(__second_tag(), __a)</div><div class="">{</div><div class=""><span class="m_5535665134301237518m_3829869060949612838m_8776782733827039247Apple-tab-span" style="white-space: pre-wrap;">  </span>__self_view __sv = __self_view(__t).substr(__pos, __n);</div><div class="">   <span class="m_5535665134301237518m_3829869060949612838Apple-converted-space"> </span>__init(__sv.data(), __sv.size());</div><div class="">#if _LIBCPP_DEBUG_LEVEL >= 2</div><div class="">   <span class="m_5535665134301237518m_3829869060949612838Apple-converted-space"> </span>__get_db()->__insert_c(this)<wbr class="">;</div><div class="">#endif</div><div class="">}</div></blockquote><div class=""><br class=""></div></div></div></blockquote><div class=""><br class=""></div><div class="">That constructor was added in C++17, so removing it along with string_view should be OK.</div><div class="">Assuming we don't use it to implement older constructors using a single template.</div><div class=""><br class=""></div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div class="" style="word-wrap: break-word;"><div class=""><div class=""></div><div class="">I suppose the decision was made so that std::string could take advantage of it.</div><div class=""><br class=""></div><div class="">Is it a conforming extension?</div></div></div></blockquote><div class=""><br class=""></div><div class="">No, because it can change the meaning of otherwise well defined code, as you pointed out initially. </div></div></div></blockquote><div class=""><br class=""></div></span><div class="">Let me know if this patch is along the right lines.  If so, I'll finish it up and put it on phab.</div><div class=""><br class=""></div><div class="">experimental/filesystem/path.c<wbr class="">pp doesn't compile, since experimental/filesystem uses things like operator+=(string, string_view) extensively.  But I'd like an early opinion on the approach before I dig in.</div><div class=""><br class=""></div><div class="">In string, the only function that needed to be rewritten was string::compare(size, size, string, size, size).  I'm nervous that filesystem will be a bigger job.</div><div class=""><br class=""></div><div class=""></div></div></div><br class=""><div class="" style="word-wrap: break-word;"><div class=""><div class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div class="" style="word-wrap: break-word;"><div class=""><div class=""><div class="m_5535665134301237518m_230594884939490540h5"><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">On Jun 15, 2017, at 18:35, Eric Fiselier <<a href="mailto:eric@efcs.ca" target="_blank" class="">eric@efcs.ca</a>> wrote:</div><br class="m_5535665134301237518m_230594884939490540m_8776782733827039247Apple-interchange-newline"><div class=""><div dir="ltr" class="">It *shouldn't* include <string_view>, that's a given.<div class=""><br class=""></div><div class="">IIRC, and Marshall would know better, I believe it was untenable to</div><div class="">maintain a version of <string> that didn't depend on <string_view> after making</div><div class="">the changes required for C++17.</div><div class=""><br class=""></div><div class="">However inspecting <string> now it does seem possible that the entanglement</div><div class="">is avoidable.Though it's also likely I'm just not seeing the whole picture. </div><div class=""><br class=""></div><div class="">/Eric</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Jun 15, 2017 at 6:42 PM, Duncan P. N. Exon Smith<span class="m_5535665134301237518m_230594884939490540Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:dexonsmith@apple.com" target="_blank" class="">dexonsmith@apple.com</a>></span>wr<wbr class="">ote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><span class=""><br class="">> On Jul 20, 2016, at 22:31, Marshall Clow via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a>> wrote:<br class="">><br class="">> Modified: libcxx/trunk/include/string<br class="">> URL:<span class="m_5535665134301237518m_230594884939490540Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=276238&r1=276237&r2=276238&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/ll<wbr class="">vm-project/libcxx/trunk/includ<wbr class="">e/string?rev=276238&r1=276237&<wbr class="">r2=276238&view=diff</a><br class="">> ==============================<wbr class="">==============================<wbr class="">==================<br class="">><br class=""></span><span class="">> @@ -435,6 +461,7 @@ basic_string<char32_t> operator "" s( co<br class="">> */<br class="">><br class="">> #include <__config><br class="">> +#include <string_view><br class=""><br class=""></span>This breaks the following, valid, C++14 code:<br class=""><br class="">   <span class="m_5535665134301237518m_230594884939490540Apple-converted-space"> </span>#include <string><br class="">   <span class="m_5535665134301237518m_230594884939490540Apple-converted-space"> </span>#include <experimental/string_view><br class="">   <span class="m_5535665134301237518m_230594884939490540Apple-converted-space"> </span>using namespace std;<br class="">   <span class="m_5535665134301237518m_230594884939490540Apple-converted-space"> </span>using std::experimental::string_view<wbr class="">;<br class="">   <span class="m_5535665134301237518m_230594884939490540Apple-converted-space"> </span>void f() { string_view sv; }<br class=""><br class="">Should <string> #include <string_view> even when we're not in C++17 mode?  Why?<br class=""><div class="m_5535665134301237518m_230594884939490540m_8776782733827039247HOEnZb"><div class="m_5535665134301237518m_230594884939490540m_8776782733827039247h5"><br class="">> #include <iosfwd><br class="">> #include <cstring><br class="">> #include <cstdio>  // For EOF.</div></div></blockquote></div></div></div></blockquote></div></div></div></div></div></blockquote></div></div></blockquote></div></div></blockquote></div></div></div></blockquote></div></div></div></div></div></div></blockquote></div></div></div></div></blockquote></blockquote></div></blockquote></div><br class=""></body></html>