boostorg / boostorg/property_tree
Problem with getting std::numeric_limits<double>::infinity()
- Dominant language
- C++
- Stars
- 65
- Forks
- 97
- PR merge metrics
- No merged PRs in 30d
Description
Example code:
```
#include
#include
#include
#include
#include
#include
int main() {
std::cout << "Boost Version: " << BOOST_VERSION << std::endl;
boost::property_tree::ptree tree;
tree.put("number", std::numeric_limits::infinity());
for (auto &[key, value] : tree)
std::cout << key << " : " << value.get_value() << std::endl;
auto number = tree.get_optional("number").get();
std::cout << "number optional : " << number << std::endl;
}
```
Example output:
```
Boost Version: 107400
number : inf
test: /usr/include/boost/boost/optional/optional.hpp:1212: boost::optional::reference_type boost::optional::get() [with T = double; boost::optional::reference_type = double&]: Assertion `this->is_initialized()' failed.
Aborted
```
Expected output:
```
Boost Version: 107400
number : inf
number optional: inf
```
Changing the `std::string` in the `get_value` to `double` results in:
```
terminate called after throwing an instance of 'boost::exception_detail::clone_impl >'
what(): conversion of data to type "d" failed
```
Problem also applies to `float` and `long double` types.
Tested in https://hub.docker.com/r/zouzias/boost/
and https://tio.run/##hVDRSsMwFH3vV1wqSAtze89qHwY@@OLAyV5EStbezWCahDQZFPHb603aqZuCL2lz7jkn59zamJtacnUYhiuhaukbhELozlnkbZl8YztN4MJYbdC6vqI5LoTa68pw26GdvxrzH92E82/iEW0ntLocUgyhDj8RKVrhujJJEqEctFyoLIf3BKBzDWO19g6KAtJVcIXt6MogDeBqvd48Vdu7x839@iEAUYKqkUvSxxyMnSWma/hAOJYJkWIB412WKt/u0Kaz0YRuaEVdjemKRvudxJIxWpBQwvVZnkf9XlvIuHcarp/fsJ/BkUuPL8Cic06MiyJEin1g6hD58wO6Kv4VkTxtiRZxXors4ltjVrgd4wexNo72wuUp6VefPIyzfPlroZPHSXjKM8Hn734Mwyc
and a system running boost 1.60
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.