Initialize a vector of pairs in one line

后端 未结 2 1310
独厮守ぢ
独厮守ぢ 2020-12-21 18:36

I want to initialize a std::vector (of std::pair), with k objects, with the pair of values shown below.

Here is my attempt:

// int k
std         


        
2条回答
  •  伪装坚强ぢ
    2020-12-21 19:01

    Assuming Point::FT is something for which numeric_limits::max() is valid,

    std::vector >
            v(k, std::make_pair(std::numeric_limits::max(), -1));
    

提交回复
热议问题