From -2387915453338050796
X-Google-Thread: f78e5,f1baa317914feeaf
X-Google-Attributes: gidf78e5,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news2.google.com!news1.google.com!news.glorb.com!news2.glorb.com!news.alt.net!frodo.cs.rpi.edu!not-for-mail
From: google@dalvander.com
Newsgroups: comp.std.c++
Subject: Re: typeof keyword
Date: Sun, 29 Mar 2009 15:51:24 CST
Organization: http://groups.google.com
Lines: 33
Sender: cppmods@cs.rpi.edu
Approved: stephen.clamage@sun.com
Message-ID: <04297129-6b1b-479e-ab60-44eb7d288725@v38g2000yqb.googlegroups.com>
References: <488de3d4-77ac-4c01-8130-d196dec70bc8@v15g2000yqn.googlegroups.com>
  <gqdl38$gtu$1@news.mixmin.net>
  <d78092d1-73d4-4e20-b93a-9d1fb2849bb3@r15g2000vbi.googlegroups.com>
  <4c6295e4-2e8d-44e3-85cd-7e9eb9e72ce0@p11g2000yqe.googlegroups.com>
NNTP-Posting-Host: netlab.cs.rpi.edu
Content-Type: text/plain; charset=ISO-8859-1
To: (Usenet)
Return-Path: <cppmods@ruralroute.cs.rpi.edu>
X-Original-Date: Sun, 29 Mar 2009 02:18:24 -0700 (PDT)
X-Submission-Address: std-c++@netlab.cs.rpi.edu
Xref: g2news2.google.com comp.std.c++:367

On Mar 27, 11:40 pm, Giovanni Deretta <gpdere...@gmail.com> wrote:
> auto x = /expression/;
>
> will be equivalent to:
>
> remove_reference<decltype(/expression/)>::type x = /expression/;

Are you sure?

Let's say I have a class which is heavy to copy assign and copy
construct: HeavyObject. And a function which returns a HeavyObject by
const-reference:
const HeavyObject& getHeavy(int howHeavy);

And then do the following:
auto heavy = getHeavy(42);

The copy constructor will be called?

Do I need to use the following to prevent the copy constructor to be
called?
const auto& heavy = getHeavy(42);

Regards,
Anders Dalvander


-- 
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



