I've tried all permutations of () and {} I could think of...
Is your question related to IO?
Read this C++ FAQ LITE article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
The initializer list is supposed to work but I don't know if gnu has implemented such an experimental feature or not. A constructor initializer sequence is still under debate, is it not? (somebody keep me updated please)
Anyhow, as it stands for now, just default initialize it and use the constructor body, or as it is with the case with c++0x, copy it from the automatic object.
Code:
myClass
{
public:
myClass()
: array_of_2_ints (array<int, 2>{1, 2}) //<- meh...
{
// or do it here
array_of_2_ints.fill(666);
}
private:
::std::array<int, 2> array_of_2_ints;
};
If you look at the boost::array, the whole ctor/ctor/dtor is done through the operator=.
I never used boost array to an extend where I can participate in a debate over it, but the simple notion that arrays can be assigned/copied makes me go "What? you can do that?"
According to this documentation there is no appropriate constructor for what you are trying to do. Where did you see the documentation that indicates that there is something other than a default constructor or copy constructor? It all looks consistent to me. You cannot provide values for elements to the constructor. You either use the initializer list or you use an algorithm within the constructor body. Unfortunately for class attributes I don't think that there is a way to use an initializer list for the array unless the array is static.
Thanks for your replies. I thought array had some sort of magic that would allow this, and I though the syntax was eluding me.
Guess I'll just initialize it in the constructor, no big deal.
Is your question related to IO?
Read this C++ FAQ LITE article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
Bookmarks