开发者

Boost array Initialization in C++

I need to declare a boost::array. I did it as boost::array<char, 116> buf; is there a possibility that I can declare with the size stored as a con开发者_运维百科stant that is initialized from property file. something like boost::array<char, BUFFER_SIZE> buf;

Any Help?


No. If you want a dynamically sizable array, use a std::vector

Reason for No is that the template parameter cannot be provided at run time (caveat: current standard)


If it's a constant available at compile-time, (meaning you #included your property file or something) then yes.

int const BUFFER_SIZE = 116;
boost::array<char, BUFFER_SIZE> buf;

is valid. If it isn't available at compile-time, then no.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜