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 #include
d 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.
精彩评论