From b037563bf97b194f80638db78ab5dd0f43eed90f Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Tue, 3 Jul 2012 17:32:29 +0000 Subject: [PATCH] Documentation update: documented optimizations for boost and std arrays (refs #7065) [SVN r79249] --- doc/lexical_cast.qbk | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/doc/lexical_cast.qbk b/doc/lexical_cast.qbk index b856594..1100666 100644 --- a/doc/lexical_cast.qbk +++ b/doc/lexical_cast.qbk @@ -70,6 +70,15 @@ The following example uses numeric data in a string expression: log_message("Error " + boost::lexical_cast(yoko) + ": " + strerror(yoko)); } `` +Following example converts some number and puts it to file: +`` + int i; + FILE* file; + ... + typedef boost::array buf_t; // You can use std::array if your compiler supports it + buf_t buffer = boost::lexical_cast(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` 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(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` and `std::array` 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.