Skip to content

Commit 0d0bd12

Browse files
committed
Add documentation of new string conversion functions
1 parent ce00fe0 commit 0d0bd12

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

doc/modules/ROOT/pages/strings.adoc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,39 @@ They construct the value as though calling `from_chars` without a specified form
3838
If the input string is invalid these constructors will `throw std::runtime_error`.
3939
If you are using a no exceptions environment instead of throwing the constructor will return a Quiet NAN.
4040

41+
== Conversions from `std::string`
42+
43+
[source,c++]
44+
----
45+
#include <boost/decimal/string.hpp>
46+
47+
namespace boost {
48+
namespace decimal {
49+
50+
inline auto stod32(const std::string& str, std::size_t* idx = nullptr) -> decimal32_t;
51+
52+
inline auto stod32f(const std::string& str, std::size_t* idx = nullptr) -> decimal_fast32_t;
53+
54+
inline auto stod64(const std::string& str, std::size_t* idx = nullptr) -> decimal64_t;
55+
56+
inline auto stod64f(const std::string& str, std::size_t* idx = nullptr) -> decimal_fast64_t;
57+
58+
inline auto stod128(const std::string& str, std::size_t* idx = nullptr) -> decimal128_t;
59+
60+
inline auto stod128f(const std::string& str, std::size_t* idx = nullptr) -> decimal_fast128_t
61+
62+
} // namespace decimal
63+
} // namespace boost
64+
----
65+
66+
Attempts conversion of `str` to the decimal type specified as if with `from_chars(str, idx)` subject to:
67+
68+
. Overflow throws `std::out_of_range` or in a no exceptions environment returns `std::numeric_limits<DecimalType>::signaling_NaN()` with unset value of `idx`.
69+
70+
. If the string can not be converted into a decimal value throws `std::out_of_range` or in a no exceptions environment returns `std::numeric_limits<DecimalType>::signaling_NaN()` with unset value of `idx`.
71+
72+
The returned value `idx` is the number of characters.
73+
4174
== `to_string`
4275

4376
[source, c++]

0 commit comments

Comments
 (0)