J
joe
Öö Tiib said:No. boost::array does usually allocate together with struct that
contains it. It is like any usual non dynamic array. Since i used
boost::make_shared<> in my example it did exactly one allocation
(allocating room both for svrlist and for shared_ptr pointing at it at
once).
No. My argument is that there is always a way to write it in C++.
The only way to get struct hack characteristics in C++ is to use the
struct hack (some version of it). C++ provides no alternative nor does it
recognize the technique. It is deficient in that regard.
That struct hack is there since C provides you no much other ways.
C99 standardizes the technique and therefor provides the only way, while
C++ has a hole in the spec for the capabilities of the struct hack.
If the
already existing things do not suit you then fine, but that hack is
ugly don't you see?
It doesn't matter how ugly it is, if it is the correct tool for the job.
In C++, when you need the struct hack, you can either build the right
thing, using the struct hack, even though it is ugly, or you can build
the wrong thing that is pretty using some inappropriate C++
construct/abstraction. Correctness vs. cosmetics.