forked from boostorg/conversion
Documentation update: documented optimizations for boost and std arrays (refs #7065)
[SVN r79249]
This commit is contained in:
@@ -70,6 +70,15 @@ The following example uses numeric data in a string expression:
|
||||
log_message("Error " + boost::lexical_cast<std::string>(yoko) + ": " + strerror(yoko));
|
||||
}
|
||||
``
|
||||
Following example converts some number and puts it to file:
|
||||
``
|
||||
int i;
|
||||
FILE* file;
|
||||
...
|
||||
typedef boost::array<char, 50> buf_t; // You can use std::array if your compiler supports it
|
||||
buf_t buffer = boost::lexical_cast<buf_t>(i); // No dynamic memory allocation
|
||||
puts(buffer.begin(), file);
|
||||
``
|
||||
[endsect]
|
||||
|
||||
[section Synopsis]
|
||||
@@ -239,12 +248,20 @@ limitation of compiler options that you use.
|
||||
, `"-inf"` (case insensitive) strings to get NaN and Inf values. `boost::lexical_cast<string>` outputs `"-nan"`, `"nan"`,
|
||||
`"inf"`, `"-inf"` strings, when has NaN or Inf input values.
|
||||
|
||||
[pre
|
||||
]
|
||||
|
||||
* [*Question:] What is the fastest way to convert a non zero terminated string or a substring using `boost::lexical_cast`?
|
||||
* [*Answer:] Use `boost::iterator_range` for conversion. For example, if you whant to convert to `int` two characters from a string `str`, you shall write `lexacal_cast<int>(make_iterator_range(str.c_str(), str.c_str() + 2));`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Changes]
|
||||
|
||||
* [*boost 1.51.0 :]
|
||||
|
||||
* Better performance, less memory usage for `boost::array<character_type, N>` and `std::array<character_type, N>` conversions.
|
||||
|
||||
* [*boost 1.50.0 :]
|
||||
|
||||
* `boost::bad_lexical_cast` exception is now globaly visible and can be catched even if code is compiled with -fvisibility=hidden.
|
||||
|
Reference in New Issue
Block a user