skystrife / cpptoml

cpptoml is a header-only library for parsing TOML

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compile error on clang while inserting float value to table

mika314 opened this issue · comments

root->insert("my_name", 1.0f);
./coefficient.cpp:12:11: error: no matching member function for call to 'insert'
    root->insert(name, value);
    ~~~~~~^~~~~~
.coddle/libs_src/cpptoml/cpptoml.h:1515:10: note: candidate function not viable: no known conversion
      from 'float' to 'const std::shared_ptr<base>' for 2nd argument
    void insert(const std::string& key, const std::shared_ptr<base>& value)
         ^
.coddle/libs_src/cpptoml/cpptoml.h:1525:10: note: candidate template ignored: substitution failure
      [with T = float &]: ambiguous partial specializations of 'value_traits<float &, void>'
    void insert(const std::string& key, T&& val,
         ^
1 error generated.
$ clang --version 
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Workaround convert to double:

root->insert("my_name", 1.0);