4

How to convert a RepeatedField<google::protobuf::uint32> to a const std::vector<double>?

Columbo
  • 60,038
  • 8
  • 155
  • 203
Dosti
  • 161
  • 4
  • 17
  • Removing each element from RepeatedField and putting it in the vector should work. – Galik Nov 28 '14 at 13:55
  • @BenjaminBannier: All (u)int32 values can be stored precisely in a double. http://stackoverflow.com/a/1848762/25488 – RobH Nov 28 '14 at 14:09

1 Answers1

15

That should be easy, since repeated fields act as containers:

void foo(RepeatedField<google::protobuf::uint32> const & f)
{
    std::vector<double> v(f.begin(), f.end());

    // use v
}
Kerrek SB
  • 464,522
  • 92
  • 875
  • 1,084