Let's do front, back, popFront, and popBack!
Michel Fortin
michel.fortin at michelf.com
Thu Jan 29 19:11:29 PST 2009
On 2009-01-29 22:02:07 -0500, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> said:
> Steven Schveighoffer wrote:
>> Will popFront and popBack return the element removed? Usually that is
>> the meaning of pop (but not always).
>
> Great question. In STL they can't because C++ couldn't move values
> reliably at the time (C++0X still can't IMHO but that's another
> discussion). D would be able to because it has good support for moving.
> I just don't want inefficiencies; returning e.g. a large struct will
> still involve some memcpying even if costly resources are not
> duplicated.
>
> So I'm ambivalent about this.
That would seem like another good use for return type overloading:
void popFront();
ElementType popFront();
Too bad we can't have that.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list