On Fri, Mar 28, 2008 at 1:59 PM, Patrick Loney <
Patrick.Loney@interactivets.com> wrote:
There are other classes that can't be used in containers such as
scoped_ptr so there is precedent - stl containers aren't the be all and
end all of software design.
> Yes, well boost::noncopyable also prohibits something :-) The whole
> intent of nondynamic is to prohibit (or make difficult) dynamic
> allocation/pointer usage.
> Do you think boost::noncopyable has a valid purpose, but nondynamic is
> less useful?
All applications of noncopyable are clearly defined in my opinion. In case of nondynamic it is not so.
If I declare a class as nondynamic I still probably can assume that it is locally copyable. Isn't is so?
So this construct should be valid:
{ //local scope
std::vector<some_nondynamic> local_collection;
local_collection.push_back(some_nondynamic(params_here)); // BOOM! Compiler error! new[] is not accessible or address is not accessible.
...
}
Do
you see the problem here? Any user who deals with nondynamic must be
aware of the internal structure of some third-party class involved
wheather it will try to allocate storage for this class to copy it more
efficiently. So in other words, you would state: I allow you to copy,
but it depends how you do that...
Where in noncopyable you state: I disallow any copies.
IMO
nondynamic will involve a whole bunche of exceptional rules when it can
be used or not, where from the point of view of an automatic variable
this should be valid or possible. So you break somehow natural
semantics.
Best Regards,
Ovanes