Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #80368

Re: [ #include <stack> ] What's the difference?

From MrSpook_mlauoyv4F_@o18rpnvgrx0dq.co.uk
Newsgroups comp.lang.c++
Subject Re: [ #include <stack> ] What's the difference?
Date 2021-06-13 08:34 +0000
Organization Aioe.org NNTP Server
Message-ID <sa4fu3$48j$1@gioia.aioe.org> (permalink)
References <sa0877$3h9$1@dont-email.me> <sa2t3t$1oqb$1@gioia.aioe.org>

Show all headers | View raw


On Sat, 12 Jun 2021 20:06:53 +0200
Manfred <noname@add.invalid> wrote:
>On 6/11/2021 7:55 PM, SIMON wrote:
>> Does anybody know the significant difference between:
>> 
>>> myStack.push(30);
>>>
>>> myStack.emplace(30);
>>>
>> It does the same thing as far as I can see but surely there must be 
>> something that I don't know about these two methods.
>> 
>> 
>> 
>
>push() takes a reference to an object that has already been constructed, 

One would hope that a modern compiler would optimise out the temporary however
so there shouldn't actually be any difference between emplace() and push()
in practice.

Back to comp.lang.c++ | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[ #include <stack> ] What's the difference? SIMON <invalid@invalid.invalid> - 2021-06-11 17:55 +0000
  Re: [ #include <stack> ] What's the difference? SIMON <invalid@invalid.invalid> - 2021-06-11 18:08 +0000
    Re: [ #include <stack> ] What's the difference? scott@slp53.sl.home (Scott Lurndal) - 2021-06-11 18:21 +0000
  Re: [ #include <stack> ] What's the difference? Richard Damon <Richard@Damon-Family.org> - 2021-06-11 14:29 -0400
  Re: [ #include <stack> ] What's the difference? Kli-Kla-Klawitter <kliklaklawitter69@gmail.com> - 2021-06-11 20:35 +0200
  Re: [ #include <stack> ] What's the difference? Manfred <noname@add.invalid> - 2021-06-12 20:06 +0200
    Re: [ #include <stack> ] What's the difference? Kli-Kla-Klawitter <kliklaklawitter69@gmail.com> - 2021-06-12 20:12 +0200
    Re: [ #include <stack> ] What's the difference? MrSpook_mlauoyv4F_@o18rpnvgrx0dq.co.uk - 2021-06-13 08:34 +0000
      Re: [ #include <stack> ] What's the difference? Öö Tiib <ootiib@hot.ee> - 2021-06-13 04:31 -0700
  Re: [ #include <stack> ] What's the difference? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-06-23 10:17 -0700
    Re: [ #include <stack> ] What's the difference? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-06-24 17:23 -0400
      Re: [ #include <stack> ] What's the difference? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-07-06 12:50 -0700
        Re: [ #include <stack> ] What's the difference? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-07-06 21:17 -0400
          Re: [ #include <stack> ] What's the difference? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-07-06 21:59 -0700

csiph-web