473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

NRVO

Hello,

I've earlier been told by MS that the upcoming C++ compiler (VS2005) should
utilize NRVO. When compiling the program below with VS2005 Aug CTP release,
it doesn't seem as it performs NRVO. What's the status of VS2005 and NRVO?

Staffan Langin
#include "stdafx.h"

#include <iostream>

struct T
{
T() {std::cout<<"D";}
T(int) {std::cout<<"D";}
T(T const&) {std::cout<<"C";}
T& operator+=(T const&) {return *this;}
};
T
f1()
{
return T();
}
T
f2()
{
T t;
return t;
}
T
f3()
{
T t;
t=T();
return t;
}
T
a1(T const& lhs,T const& rhs)
{
T t(lhs);
t+=rhs;
return t;
}
T
a2(T const& lhs,T const& rhs)
{
T t=lhs;
t+=rhs;
return t;
}
int _tmain(int argc, _TCHAR* argv[])
{
std::cout<<"min D max D = ";
T t1;
std::cout<<std::endl;
std::cout<<"min D max DC = ";
T t2(T(1));
std::cout<<std::endl;
std::cout<<"min D max DC = ";
T t3=T();
std::cout<<std::endl;
std::cout<<"min D max DCC = ";
T t4(f1());
std::cout<<std::endl;
std::cout<<"min D max DCC = ";
T t5=f1();
std::cout<<std::endl;
std::cout<<"min D max DCC = ";
T t6(f2());
std::cout<<std::endl;
std::cout<<"min D max DCC = ";
T t7=f2();
std::cout<<std::endl;
std::cout<<"min DD max DDCC = ";
T t8(f3());
std::cout<<std::endl;
std::cout<<"min DD max DDCC = ";
T t9=f3();
std::cout<<std::endl;
std::cout<<"min C max CCC = ";
T u1(a1(t1,t2));
std::cout<<std::endl;
std::cout<<"min C max CCC = ";
T u2=a1(t1,t2);
std::cout<<std::endl;
std::cout<<"min C max CCC = ";
T u3(a2(t1,t2));
std::cout<<std::endl;
std::cout<<"min C max CCC = ";
T u4=a2(t1,t2);
std::cout<<std::endl;
return 0;
}
Output:

min D max D = D
min D max DC = D
min D max DC = D
min D max DCC = D
min D max DCC = D
min D max DCC = DC
min D max DCC = DC
min DD max DDCC = DDC
min DD max DDCC = DDC
min C max CCC = CC
min C max CCC = CC
min C max CCC = CC
min C max CCC = CC
Nov 17 '05 #1
4 1315
http://msdn.microsoft.com/chats/tran...io_022703.aspx

Here you can read:
Host: Jeff (Microsoft)
Q: I am surprised to hear that Everett does not implement RVO. Does it
implement NRVO (named-RVO) at all?

A: We do RVO, just not NRVO.
--
Un saludo
Rodrigo Corral González [MVP]

FAQ de microsoft.public.es.vc++
http://rcorral.mvps.org

Nov 17 '05 #2
> http://msdn.microsoft.com/chats/tran...io_022703.aspx

Here you can read:
Host: Jeff (Microsoft)
Q: I am surprised to hear that Everett does not implement RVO. Does it
implement NRVO (named-RVO) at all?

A: We do RVO, just not NRVO.


Rodrigo,

That transcript seems to refer to VS2003 (Everett) and not VS2005. If one
looks at the output from the program in my original post, VS2005 Aug CTP
release also seems to support RVO but not NRVO but I'd like someone from MS
to confirm that's the specification of the final version aswell.

Staffan
Nov 17 '05 #3
Staffan Langin wrote:
Hello,

I've earlier been told by MS that the upcoming C++ compiler (VS2005) should
utilize NRVO. When compiling the program below with VS2005 Aug CTP release,
it doesn't seem as it performs NRVO. What's the status of VS2005 and NRVO?


I heard that it was implemented, but only for release builds. Did you
compile with optimization enabled? See:

http://groups.google.co.uk/group/mic...e=source&hl=en

Tom
Nov 17 '05 #4
> I heard that it was implemented, but only for release builds. Did you
compile with optimization enabled? See:

http://groups.google.co.uk/group/mic...e=source&hl=en

Tom,

Thanks a lot for you reply. It indeed seems as NRVO is enabled when
compiling a release build. This is very good news for me as VS2005 now seems
to be viable option for my project. Again, thanks for your reply.

Staffan Langin
Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

45
by: Jamie Burns | last post by:
Hello, I realise that I just dont get this, but I cannot see the need for auto_ptr. As far as I have read, it means that if you create an object using an auto_ptr, instead of a raw pointer, then...
20
by: Jakob Bieling | last post by:
Hi! I am using VC++ 7.1 and have a question about return value optimization. Consider the following code: #include <list> #include <string> struct test {
16
by: gorda | last post by:
Hello, I am playing around with operator overloading and inheritence, specifically overloading the + operator in the base class and its derived class. The structure is simple: the base class...
111
by: JKop | last post by:
Okay here we go, I feel it's about time people conversed about the bullshit aspects of C++ (including the bullshit stuff brought forward from C). I'll begin with a few of my own grievances: 1)...
25
by: Victor Bazarov | last post by:
In the project I'm maintaining I've seen two distinct techniques used for returning an object from a function. One is AType function(AType const& arg) { AType retval(arg); // or default...
29
by: pmatos | last post by:
Hi all, Sometimes I have a function which creates an object and returns it. Some are sets, other vectors but that's not very important. In these cases I do something like this: vector<int> *...
11
by: Alexander Stippler | last post by:
Hi I have already posted and discussed the following problems once, but despite really helpful hints I did not get any further with my problem (I at least learned, first to exactly consider why...
18
by: terminator(jam) | last post by:
consider: struct memory_pig{//a really large type: memory_pig(){ std::cout<<"mem pig default\n"; //etc... }; memory_pig(memory_pig const&){
17
by: Klaas Vantournhout | last post by:
Hi all, I was wondering if it is possible if you can check in a function if one of the arguments is temporary. What I mean is the following. A is a class, foo is a function returning a class...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.