Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Jonathan Lamothe Newsgroups: comp.lang.c++ Subject: Re: Move semantics with literals Date: Tue, 14 Apr 2026 11:01:22 -0400 Organization: A noiseless patient Spider Lines: 24 Message-ID: <87jyu960xp.fsf@posteo.de> References: <10rlkk9$6hau$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Injection-Date: Tue, 14 Apr 2026 15:01:23 +0000 (UTC) Injection-Info: dont-email.me; posting-host="802fe6a8d5b97504ac6764022e672b27"; logging-data="163865"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+6vsvKqb+MIzFEcybVAZwKiqrX0janLzw=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Cancel-Lock: sha1:j16gMT7NrGFke+KufombxRSlL8g= sha1:Rycr1PfonYoSkiu0QQjjezbQDH4= Xref: csiph.com comp.lang.c++:123718 boltar@caprica.universe writes: > To my chagrin I got caught out by this trick question in an interview: > > int func(int &&a) > { > return a * 2; > } > > > : > int b = func(123); > : > > Where the question was "what would happen". I assumed it wouldn't compile > being a reference to a literal but it does. So I'm just wondering why on > earth and when would you ever do the above? Is there some wierd use case? The only use case I can see is tricky interview questions. ;) -- Regards, Jonathan Lamothe https://jlamothe.net