Skip to content

Populating the toml table as required by the user #157

Description

@ravipathuri

Hello
I currently use v3.6.0 version of the tomll11 header only library. The parsing part work as expected. But i see few issues w.r.t populating the toml table content in the order as required by the user.
This is a demo program
#include "toml.hpp" // that's all! now you can use it.
#include
#include
#include
int main()
{
toml::value data{{"foo", 42}, {"bar", 3.14}, {"baz", "qux"}};
data["hoge"] = "piyo";
std::stringstream ss;
ss << std::setw(0) << data;
std::cout<<"Actual toml content\n"<<ss.str();
return 0;
}
The output is
Actual toml content
hoge = "piyo"
baz = "qux"
foo = 42
bar = 3.14

It should have been
Actual toml content
hoge = "piyo"
baz = "qux"
bar = 3.14
foo = 42

Any reason for this behaviour?
over-riding the type the std::map will just place the keys in alphabetical order(sorted manner). But in my case i want the key value pairs to be in the order as they are passed. How can we achieve this?
Please give your inputs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions