Re:Re: [boost]Re: Re: [serialization] non-conformance

Robert Ramey wrote:
This exchange illustrates the problem rather nicely. Its not clear to me from the name "aligned_storage" that its meant to do the same job as "stack_allocate" and in fact is easily confused with other boost functions. I've been able to find no documentation nor test nor other information. The only place its used is in variant.hpp but its not mentioned in the documentation of that either. There is no statement in the header itself as to what it does and the code is sufficiently non-trivial that it's not obvious what its supposed to do. The fact that it has a parameter than stack_allocate doesn't need also suggests that it's intended purpose is different from that of stack_allocate.
The previous post referred to alignment_of rather than aligned_storage which seems to me to unrelated. Are they related in some non-obvious (to me) way? What's incorrect about my statement above?
It doesn't, see aligned_storage's "Rationale" subsection in http://tinyurl.com/39asx.
Is this part of boost documentation and tests? Robert Ramey

Robert Ramey wrote:
Robert Ramey wrote:
This exchange illustrates the problem rather nicely. Its not clear to me from the name "aligned_storage" that its meant to do the same job as "stack_allocate" and in fact is easily confused with other boost functions. I've been able to find no documentation nor test nor other information. The only place its used is in variant.hpp but its not mentioned in the documentation of that either. There is no statement in the header itself as to what it does and the code is sufficiently non-trivial that it's not obvious what its supposed to do. The fact that it has a parameter than stack_allocate doesn't need also suggests that it's intended purpose is different from that of stack_allocate.
The previous post referred to alignment_of rather than aligned_storage which seems to me to unrelated. Are they related in some non-obvious (to me) way?
They are realted. A typical usage of 'aligned_storage' for storing a single T would be aligned_storage< sizeof(T), alignment_of<T>::value > which is basically equivalent to what your 'stack_allocate' is aiming for. It would be useful to have a higher-level wrapper template for this particular use case, so, assuming that 'stack_allocate' is going to be fixed to use 'algined_storage' in its implementation, you are more than welcome to promote it into a public compoment (with a better name, I hope).
What's incorrect about my statement above?
You are totally right to raise the documentation issue. You were wrong to assume that 'algined_storage' is intended to serve a different purspose.
It doesn't, see aligned_storage's "Rationale" subsection in http://tinyurl.com/39asx.
Is this part of boost documentation and tests?
No, and it should be. Eric, John? -- Aleksey Gurtovoy MetaCommunications Engineering

Aleksey Gurtovoy wrote:
Robert Ramey wrote: [snip]
Is this part of boost documentation and tests?
No, and it should be. Eric, John?
Yes, there should be documentation for aligned_storage. I never got around to it, unfortunately. I'll add it to my list of things to do. One issue though-- there is a disparity between boost::aligned_storage and std::tr1::aligned_storage. Namely, the latter is much like boost::type_with_alignment whereas the former provides usable aligned storage of the specified size. Before I write any documentation, it would be useful to decide whether the existing behavior (or naming) of boost::aligned_storage should change. Input? Eric

On Sun, 7 Mar 2004 15:44:22 -0800, "Robert Ramey" <ramey@rrsd.com> wrote:
Robert Ramey wrote:
This exchange illustrates the problem rather nicely. Its not clear to me from the name "aligned_storage" that its meant to do the same job as "stack_allocate" and in fact is easily confused with other boost functions. I've been able to find no documentation nor test nor other information. The only place its used is in variant.hpp but its not mentioned in the documentation of that either. There is no statement in the header itself as to what it does and the code is sufficiently non-trivial that it's not obvious what its supposed to do. The fact that it has a parameter than stack_allocate doesn't need also suggests that it's intended purpose is different from that of stack_allocate.
The previous post referred to alignment_of rather than aligned_storage which seems to me to unrelated. Are they related in some non-obvious (to me) way?
aligned_storage can be (and in fact is) implemented in terms of alignment_of and type_with_alignment. Even if you don't want to use aligned_storage, since it isn't a full part of boost yet (it didn't ship with the last release), you could use use type traits to implement your own correct stack_allocate function. e.g. template<class T> struct stack_allocate { union { char a[sizeof(T)]; type_with_alignment<alignment_of<T>::value>::type b; } mem; T * address(){ void * vptr = &mem; return static_cast<T *>(vptr); } T & reference(){ return * address(); } }; or something like that. Tom -- C++ FAQ: http://www.parashift.com/c++-faq-lite/ C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
participants (4)
-
Aleksey Gurtovoy
-
Eric Friedman
-
Robert Ramey
-
Tom Widmer