Opened 11 years ago
Closed 10 years ago
#6663 closed Feature Requests (fixed)
Avoiding input copying
Reported by: | Owned by: | Antony Polukhin | |
---|---|---|---|
Milestone: | Boost 1.52.0 | Component: | lexical_cast |
Version: | Boost 1.48.0 | Severity: | Problem |
Keywords: | Cc: |
Description
I think lexical_cast is optimized for std::string, as shown at http://www.boost.org/doc/libs/1_49_0/doc/html/boost_lexical_cast/performance.html 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)?
Change History (20)
comment:1 by , 11 years ago
follow-up: 4 comment:3 by , 11 years ago
This might be a use for string_ref
, which I've been itching to get into boost.
See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3334.html
comment:4 by , 11 years ago
Replying to marshall:
This might be a use for
string_ref
, which I've been itching to get into boost.See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3334.html
I love the idea[[BR]] Also, I was thinking about providing optimized conversions for iterator_range<SOME_CHAR_TYPE> (described in ticket #6430). 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.
comment:5 by , 11 years ago
Hehe, that can't be a coincedence. :p
http://code.google.com/p/xbt/source/browse/trunk/xbt/misc/xbt/data_ref.h#133
comment:6 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:7 by , 11 years ago
No (const char*, size_t) overload? :(
In the examples, you might want to use size() instead of length(). size() is used more often.
comment:8 by , 11 years ago
Updated documentation in r77537
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).
comment:9 by , 11 years ago
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.
comment:10 by , 11 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
I'll add (const CharT*, size_t) overloads after dealing with #6717. But I don't think that (const CharT*, size_t) overloads will appear in 1.50 release.
comment:11 by , 11 years ago
comment:12 by , 11 years ago
comment:13 by , 11 years ago
comment:14 by , 10 years ago
follow-up: 16 comment:15 by , 10 years ago
Shouldn't you use data() instead of c_str()? The terminator isn't required.
follow-up: 18 comment:16 by , 10 years ago
Replying to Olaf van der Spek <olafvdspek@…>:
Shouldn't you use data() instead of c_str()? The terminator isn't required.
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)
comment:17 by , 10 years ago
comment:18 by , 10 years ago
Replying to apolukhin:
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)
Don't know, but I doubt it.
comment:19 by , 10 years ago
(In [80409]) Merge from trunk: 1) #warning replaced with #error (refs #7228) 2) Pavel Korzh added to thanks list (refs #7157) 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 CharType* chars, std::size_t count) function overload (refs #6430 and refs #6663) 8) Fixed GCC warning in numeric_cast_test.cpp 9) Fix compilation of lexical cast with MSVC 2003 (refs #7255)
comment:20 by , 10 years ago
Milestone: | To Be Determined → Boost 1.52.0 |
---|---|
Resolution: | → fixed |
Status: | reopened → closed |
Lexical cast has optimizations for almost all basic input types (char*, signed char*, unsigned char*, std::string, std::wstring, char, int, ...)
Are you just requesting an additional overload with (const char*, size_t) parameters?