1

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 constant that is initialized from property file. something like boost::array<char, BUFFER_SIZE> buf;

Any Help?

2 Answers 2

5

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)

Sign up to request clarification or add additional context in comments.

Comments

3

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.