Boost C++ Libraries: Ticket #6663: Avoiding input copying https://svn.boost.org/trac10/ticket/6663 <p> I think lexical_cast is optimized for std::string, as shown at <a href="http://www.boost.org/doc/libs/1_49_0/doc/html/boost_lexical_cast/performance.html">http://www.boost.org/doc/libs/1_49_0/doc/html/boost_lexical_cast/performance.html</a> Is it possible to take advantage of this optimization for other string types as well? For example, by providing an overload for (const char*, size_t)? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6663 Trac 1.4.3 anonymous Thu, 08 Mar 2012 18:49:24 GMT <link>https://svn.boost.org/trac10/ticket/6663#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6663#comment:1</guid> <description> <p> Lexical cast has optimizations for almost all basic input types (char*, signed char*, unsigned char*, std::string, std::wstring, char, int, ...)<br /> Are you just requesting an additional overload with (const char*, size_t) parameters?<br /> </p> </description> <category>Ticket</category> </item> <item> <author>Olaf van der Spek <olafvdspek@…></author> <pubDate>Thu, 08 Mar 2012 18:51:54 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6663#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6663#comment:2</guid> <description> <p> Yes, as the input isn't (and can't be) null-terminated. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Thu, 08 Mar 2012 19:00:05 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6663#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6663#comment:3</guid> <description> <p> This might be a use for <code>string_ref</code>, which I've been itching to get into boost. </p> <p> See <a class="ext-link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3334.html"><span class="icon">​</span>http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3334.html</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Thu, 08 Mar 2012 19:04:14 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6663#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6663#comment:4</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6663#comment:3" title="Comment 3">marshall</a>: </p> <blockquote class="citation"> <p> This might be a use for <code>string_ref</code>, which I've been itching to get into boost. </p> <p> See <a class="ext-link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3334.html"><span class="icon">​</span>http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3334.html</a> </p> </blockquote> <p> I love the idea[[BR]] Also, I was thinking about providing optimized conversions for iterator_range&lt;SOME_CHAR_TYPE&gt; (described in ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6430" title="#6430: Feature Requests: Optimized code for `boost::iterator_range&lt;std::string::iterator&gt;` (closed: wontfix)">#6430</a>). I think it would be a good solution for situations, when input chars are not NULL terminated. Such approach will be described in FAQ section of lexical_cast documentation. </p> </description> <category>Ticket</category> </item> <item> <author>Olaf van der Spek <olafvdspek@…></author> <pubDate>Thu, 08 Mar 2012 19:06:20 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6663#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6663#comment:5</guid> <description> <p> Hehe, that can't be a coincedence. :p </p> <p> <a class="ext-link" href="http://code.google.com/p/xbt/source/browse/trunk/xbt/misc/xbt/data_ref.h#133"><span class="icon">​</span>http://code.google.com/p/xbt/source/browse/trunk/xbt/misc/xbt/data_ref.h#133</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Sat, 24 Mar 2012 19:35:22 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6663#comment:6 https://svn.boost.org/trac10/ticket/6663#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/77517" title="Fixes #6663 (much more optimizations for iterator_range, updated ...">[77517]</a>) Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6663" title="#6663: Feature Requests: Avoiding input copying (closed: fixed)">#6663</a> (much more optimizations for iterator_range, updated documentation and performance test results) </p> Ticket olafvdspek@… Sat, 24 Mar 2012 21:59:47 GMT <link>https://svn.boost.org/trac10/ticket/6663#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6663#comment:7</guid> <description> <p> No (const char*, size_t) overload? :( </p> <p> In the examples, you might want to use size() instead of length(). size() is used more often. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Sun, 25 Mar 2012 05:45:11 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6663#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6663#comment:8</guid> <description> <p> Updated documentation in <a class="changeset" href="https://svn.boost.org/trac10/changeset/77537" title="Small documentation updates for #6663">r77537</a> <br /> Still thinking about (const CharT*, size_t) overloads. Lexical_cast was initially designed to be a wrapper around stream input and output operators. However (const CharT*, size_t) overloads will add some syntax sugar and reduce compilation time (less metaprogramming can be used). </p> </description> <category>Ticket</category> </item> <item> <author>olafvdspek@…</author> <pubDate>Sun, 25 Mar 2012 20:51:39 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6663#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6663#comment:9</guid> <description> <p> It'd still use stream input operators, right? To me, that overload is the logical base of optimizations for other overloads, like const char* and std::string. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Mon, 26 Mar 2012 18:48:46 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/6663#comment:10 https://svn.boost.org/trac10/ticket/6663#comment:10 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> I'll add (const CharT*, size_t) overloads after dealing with <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6717" title="#6717: Bugs: Get rid of swprintf (closed: fixed)">#6717</a>. But I don't think that (const CharT*, size_t) overloads will appear in 1.50 release. </p> Ticket Antony Polukhin Mon, 16 Apr 2012 17:13:14 GMT <link>https://svn.boost.org/trac10/ticket/6663#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6663#comment:11</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/78015" title="Comment out bad advise in documentation ( refs #6786, refs #6663)">[78015]</a>) Comment out bad advise in documentation ( refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6786" title="#6786: Feature Requests: Deduce stream character type for user-defined classes (closed: fixed)">#6786</a>, refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6663" title="#6663: Feature Requests: Avoiding input copying (closed: fixed)">#6663</a>) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Tue, 17 Apr 2012 16:27:54 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6663#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6663#comment:12</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/78044" title="Update documentation ( more info about stream character type detection ...">[78044]</a>) Update documentation ( more info about stream character type detection + warn about new unicode types support; refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6786" title="#6786: Feature Requests: Deduce stream character type for user-defined classes (closed: fixed)">#6786</a>, refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6663" title="#6663: Feature Requests: Avoiding input copying (closed: fixed)">#6663</a>) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Wed, 18 Apr 2012 04:09:52 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6663#comment:13 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6663#comment:13</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/78059" title="Merge lexical_cast library from trunk: * multiple optimizations and ...">[78059]</a>) Merge lexical_cast library from trunk: </p> <ul><li>multiple optimizations and bugfixes for boost::iterator_range (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6786" title="#6786: Feature Requests: Deduce stream character type for user-defined classes (closed: fixed)">#6786</a>, refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6430" title="#6430: Feature Requests: Optimized code for `boost::iterator_range&lt;std::string::iterator&gt;` (closed: wontfix)">#6430</a>, refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6663" title="#6663: Feature Requests: Avoiding input copying (closed: fixed)">#6663</a>) </li><li>documentation update </li><li>new Unicode characters support updated </li><li>much more tests, removed incorrect tests </li></ul> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Tue, 28 Aug 2012 20:31:19 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6663#comment:14 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6663#comment:14</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/80291" title="Added lexical_cast(const CharType* chars, std::size_t count) function ...">[80291]</a>) Added lexical_cast(const <a class="missing wiki">CharType</a>* chars, std::size_t count) function overload (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6430" title="#6430: Feature Requests: Optimized code for `boost::iterator_range&lt;std::string::iterator&gt;` (closed: wontfix)">#6430</a> and refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6663" title="#6663: Feature Requests: Avoiding input copying (closed: fixed)">#6663</a>) Fixed GCC warning in numeric_cast_test.cpp </p> </description> <category>Ticket</category> </item> <item> <author>Olaf van der Spek <olafvdspek@…></author> <pubDate>Tue, 28 Aug 2012 21:05:46 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6663#comment:15 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6663#comment:15</guid> <description> <p> Shouldn't you use data() instead of c_str()? The terminator isn't required. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Mon, 03 Sep 2012 17:21:18 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6663#comment:16 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6663#comment:16</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6663#comment:15" title="Comment 15">Olaf van der Spek &lt;olafvdspek@…&gt;</a>: </p> <blockquote class="citation"> <p> Shouldn't you use data() instead of c_str()? The terminator isn't required. </p> </blockquote> <p> You are right, that would be more appropriate. Just out of curiosity: modern std::basic_string implementations make a difference between data() and c_str()? (Looked through GCC sources, both calls are evaluated to _M_data(); call) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Mon, 03 Sep 2012 17:23:19 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6663#comment:17 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6663#comment:17</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/80377" title="Replace .c_str() with .data() in documentation (refs #6663)">[80377]</a>) Replace .c_str() with .data() in documentation (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6663" title="#6663: Feature Requests: Avoiding input copying (closed: fixed)">#6663</a>) </p> </description> <category>Ticket</category> </item> <item> <author>Olaf van der Spek <olafvdspek@…></author> <pubDate>Mon, 03 Sep 2012 17:35:01 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6663#comment:18 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6663#comment:18</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6663#comment:16" title="Comment 16">apolukhin</a>: </p> <blockquote class="citation"> <p> Just out of curiosity: modern std::basic_string implementations make a difference between data() and c_str()? (Looked through GCC sources, both calls are evaluated to _M_data(); call) </p> </blockquote> <p> Don't know, but I doubt it. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Wed, 05 Sep 2012 18:23:43 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6663#comment:19 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6663#comment:19</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/80409" title="Merge from trunk: 1) #warning replaced with #error (refs #7228) 2) ...">[80409]</a>) Merge from trunk: 1) #warning replaced with #error (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7228" title="#7228: Bugs: Bugs: #warning in lexical_cast.hpp causes MSVC compile error (closed: fixed)">#7228</a>) 2) Pavel Korzh added to thanks list (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7157" title="#7157: Bugs: [lexical_cast] convert volatile int to string cause Run-Time Check ... (closed: fixed)">#7157</a>) 3) BOOST_NOEXCEPT modifiers added where possible 4) better support for c++11 Unicode characters 5) fixed compilation with MSVC+STLPort 6) more agressive usage of Traits template parameter 7) Added lexical_cast(const <a class="missing wiki">CharType</a>* chars, std::size_t count) function overload (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6430" title="#6430: Feature Requests: Optimized code for `boost::iterator_range&lt;std::string::iterator&gt;` (closed: wontfix)">#6430</a> and refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6663" title="#6663: Feature Requests: Avoiding input copying (closed: fixed)">#6663</a>) 8) Fixed GCC warning in numeric_cast_test.cpp 9) Fix compilation of lexical cast with MSVC 2003 (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7255" title="#7255: Bugs: lexical_cast is broken on MSVC .NET 2003 (closed: fixed)">#7255</a>) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Sat, 15 Sep 2012 07:33:23 GMT</pubDate> <title>status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/6663#comment:20 https://svn.boost.org/trac10/ticket/6663#comment:20 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.52.0</span> </li> </ul> Ticket