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 13:36:51 -0400 Organization: A noiseless patient Spider Lines: 45 Message-ID: <87pl414f64.fsf@posteo.de> References: <10rlkk9$6hau$1@dont-email.me> <87jyu960xp.fsf@posteo.de> <10rlldg$6qiv$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Injection-Date: Tue, 14 Apr 2026 17:36:52 +0000 (UTC) Injection-Info: dont-email.me; posting-host="802fe6a8d5b97504ac6764022e672b27"; logging-data="275451"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX182mkdN7I19PXfeXH52Pv9lLrNqlR8BDGw=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Cancel-Lock: sha1:Ftql5kNQvNDhwQxyy2KUtnEcJ+k= sha1:lAfuYkHST5U5qk/oJihBwLs/USE= Xref: csiph.com comp.lang.c++:123730 scott@slp53.sl.home (Scott Lurndal) writes: > boltar@caprica.universe writes: >>On Tue, 14 Apr 2026 11:01:22 -0400 >>Jonathan Lamothe gabbled: >>>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. ;) >> >>Unfortunately it was that kind of interview where they tried to catch you >>out rather than testing your code writing and debugging abilities. Luckily I >>wasn't fooled by the other questions though it does make me wonder if I'd want >>to work in a place that has this kind of moronic interview process. >> > > I dunno, perhaps they're doing it intentionally to weed out > candidates that did not object to the the silly test? That's one of the few reasons I would accept as valid. I have my doubts however as to whether this is what they ware actually doing. In my experience, most employers don't like it when their employees push back on nonsense. -- Regards, Jonathan Lamothe https://jlamothe.net