Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: no match for 'operator<<' #73

Open
jwcodee opened this issue Jul 8, 2019 · 4 comments
Open

error: no match for 'operator<<' #73

jwcodee opened this issue Jul 8, 2019 · 4 comments

Comments

@jwcodee
Copy link

jwcodee commented Jul 8, 2019

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?

@ToruNiina
Copy link
Owner

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;

ToruNiina added a commit that referenced this issue Jul 10, 2019
@jwcodee
Copy link
Author

jwcodee commented Jul 10, 2019

Thanks for the quick response. I'll try it out as soon as possible.

@jwcodee
Copy link
Author

jwcodee commented Jul 22, 2019

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);

@ToruNiina
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants