Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type conversion to vector in C++

Tags:

c++

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

like image 667
Dosti Avatar asked Oct 24 '25 06:10

Dosti


1 Answers

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
}
like image 146
Kerrek SB Avatar answered Oct 26 '25 20:10

Kerrek SB