Coder Social home page Coder Social logo

Parsing a vector of floats about toml11 HOT 2 CLOSED

toruniina avatar toruniina commented on May 14, 2024
Parsing a vector of floats

from toml11.

Comments (2)

ToruNiina avatar ToruNiina commented on May 14, 2024

The behavior is intended, at least on the current stage.

It is because toml::get<array_like_type> calls toml::get<element_type> internally and currently tom::get does not convert Integer to Float.

The reason why toml::get does not convert Integer to Float is that toml::get<double> can return an lvalue-reference through which we can modify the content of toml::value. To do that, since we cannot return a reference of a value in a function scope, I need to prohibit conversions. As the conversion from Integer to double is not supported, I also disabled conversions between Integer and float, for the consistency.

I know the behavior is useful (actually, sometimes I myself also want this functionality). I'm considering implementing a function toml::as that converts Integer to Float and any other possible conversions. But I'm also worrying that having both toml::get and toml::as might be confusing.

from toml11.

qukhan avatar qukhan commented on May 14, 2024

I see your point. I'm not sure I have any idea of how to improve this so I'll close the issue for now.

I think I'll create a custom type that can set a float from an integer for the time being.

from toml11.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.