error: no match for 'operator<<'
error: no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>} ' and 'const std::unordered_map<std::__cxx11::basic_string<char>, toml::basic_value<toml::discard_comments, std::unordered_map, std::vector> >') std::cout << data << std::endl; Can you assist me with this error?
I've only added in the following code const auto data = toml::table{{"foo", 42}, {"bar", "baz"}}; std::cout << data << std::endl; from the README
I imported the header library via #include "toml11/toml.hpp" instead of installing it and importing it. Could this be the reason?
Sorry, it's my failure. I found I didn't update the corresponding section in README from v2 to 3.
With the latest code, you need to pass toml::value to streams. Could you replace the toml::table to toml::value like this?
const auto data = toml::value{{"foo", 42}, {"bar", "baz"}};
std::cout << data << std::endl;
Thanks for the quick response. I'll try it out as soon as possible.
I'm getting a different error now.
In file included from toml11/toml/types.hpp:8:0,
from toml11/toml/parser.hpp:9,
from toml11/toml.hpp:36,
from toml-test.cpp:1:
toml11/toml/comments.hpp: In member function ‘toml::preserve_comments::iterator toml::preserve_comments::insert(toml::preserve_comments::const_iterator, const string&)’:
toml11/toml/comments.hpp:86:36: error: no matching function for call to ‘std::vector<std::basic_string<char> >::insert(toml::preserve_comments::const_iterator&, const string&)’
return comments.insert(p, x);
I couldn't reproduce the error in my local machine. Here is my code.
#include "toml.hpp"
#include <iostream>
int main()
{
toml::basic_value<toml::preserve_comments> v(42);
v.comments().insert(v.comments().begin(), " some comments");
std::cout << v << std::endl;
return 0;
}
And what I did is
$ g++ test.cpp -std=c++11 -Wall -Wextra -Wpedantic
$ ./a.out
42 # some comments
Could you tell me what code did you wrote?