Whats wrong (or "bad") with value-based containers?
We use them all the time.
Well, as pertaining to the topic of this thread, they require some
level of built-in type behavior of class objects to be "contained" by
them.
classes also are convenient, but not necessary/important. There are many
wide-spread languages without classes.
I think the class concept IS important (read, it is to me in the OO
style of programming I choose to use). Why bring that up though? If
you want to be extreme, as you no doubt wanted to be, only life or
death situations are ever important, so please try not to post just to
be argumentative not adding anything relevent to the topic at hand,
thx. Every thread in clc++ shouldn't tangent off into endless
directions; rather, efforts should be made to stay on topic.
You question value-based containers in C++ but you didn't tell us what
you would propose as an alternative. How would you design a container?
No, I questioned the value of class objects behaving like built-in
types weighed against the machinery required to get that.
Whats the complexity you want to avoid in the first place? The copy
constructors and copy assignment? You only need to define them, if the
compiler generated ones don't fit. If you can't define a copy
constructor (because the class is logically non-copyable), you can
forbid copying.
That's turning around the question really. I'm out looking for a
simple(st) and (most) elegant solution. As in, "what is the minimum
machinery/mechanism needed to get class objects in support of OO
programming?". If there are "heavyweight" classes and "lightweight"
ones, maybe there are some programming design guidelines to apply at
the minimum, or maybe "refactoring" of the language itself may be a
good idea.
Linked lists of ints? I guess 'none'. For ints, a std::vector would be a
better default choice. But why should we forbid std::list<int>?
You said "forbid", not me. If you want to paraphrase my thought, it
would go something like the following: "why penalize everything for
the special case?".
A container is an abstract concept.
A container _interface_ is an abstraction. But any given container
must indeed have an implementation. The interface is not the
container. The interface just allows you to work with the actual
container (the implementation). A remote control is not a television,
it just allows you to control the TV.
An array is a specific instance of
this concept. A linked list is another kind of container.
What do you think a container is?
See above for an idea.
To discuss this further, you would have to tell us what makes something
a "built-in type". What would be different, if an int in C++ wouldn't be
a built-in type?
Those are questions I posed to the lower-level guys in here as needed
elementary information that would help analyze the usefulness/
necessity/or-opposite of class objects behaving like built-in types.
Again though, the way you asked above is to turn around my original
question which is not should built-ins be of class type (which as
noted may work and does work in other languages) but rather how
valuable is it that class objects behave like built in types. Making
built-ins class types would be in the opposite direction of the goal
that spawned my question. If class objects aren't required to behave
like built-ins, or if a certain subset of these things we call "class
objects" don't have to, where is that line to be drawn and what
simplification potential does that bring (or other potential
benefits).