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.

user2155055
  • 73
  • 1
  • 1
  • 3

1 Answers1

12

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>>();
Jesse Beder
  • 33,081
  • 21
  • 109
  • 146