7

A total noob with yaml-cpp. I have a node something like this:

numbers : [1,2,3,4,5]

In the CPP file, I want to parse into a vector:

std::vector<int> vi = node["numbers"];

This doesn't work. I can't find any documentation other than the tutorial- and it isn't covered in the tutoral.

1 Answer 1

13

yaml-cpp already has overloads for standard container types, so the as<T>() function works here:

std::vector<int> vi = node["numbers"].as<std::vector<int>>();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.