🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Size doesn't really matters...right?

Started by
54 comments, last by JoeJ 6 years, 9 months ago
8 minutes ago, MarcusAseth said:

seriously, I don't know nor care for C++98, this other aproach won't work... whatever the point you're trying to make is, you're only obfuscating it more... 

C++98 is just the 1st C++ standard.

C++11/14 are two recent standards (3th and 4th, respectively) which differentiate between lvalues and rvalues.

C++98 already supported assignment operators. The compiled C++98 code of all the code snippets in this topic would do exactly the same as C++11/14 code (backwards compatibility). So you do not use or exploit any new feature of C++11/14. So you cannot (wrongly) use lvalue/rvalue argumentation because it clearly is independent of lvalues/rvalues. It has nothing to do with lvalues/rvalues like I said. It is just implicit constness.

If you won't believe this, go to http://cpp.sh/ and select C++98 for compilation.

🧙

Advertisement

And why are you blindly assuming my point is exploiting some nifty trick of C++ 11/14?!

I went and checked the C++ draft from the 97, and the quote I posted in the page before was already there at the time.

At this point I don't see any point in keep arguing, because you are simply not even considering the proof I'm showing you.

15 minutes ago, matt77hias said:

C++98 is just the 1st C++ standard.

C++11/14 are two recent standards (3th and 4th, respectively) which differentiate between lvalues and rvalues.

And this is completely wrong. 

C++98 differentiate between lvalue and rvalue, in C++ 11 and 14 there is simply more differentiation(6 categories or something)

Clearly you are confused in this and are not putting a serious effort to read the proof I show you or to reason together about it (meaning you have already decided what you want to believe), so I won't continue to try and convince you.

Maybe it helps to differentiate between string and int: String is a class or struct, while int is... primitive or built in type? Not sure about terminology.

3 hours ago, MarcusAseth said:

Why this code below compiles:



string f(string& n)
{
	return n += "99";
}

int main() {
	string a = "";
	string b = "!!!";
	
	f(a) = b;//COMPILE
}

While the one below doesnt?



int f(int& n)
{
	return n += 99;
}

int main()
{
	int a = 1;
	int b = 7;

	f(a) = b;//WON'T COMPILE
}

Both functions return by value and take an argument by reference.

The first example makes little sense, but a will be "99", and b "!!!"

The second example makes no sense, because the returned value from f does not exist (because you don't use it, compiler does not create it), so you can't assign b to it.

Back to the first example, here the compiler could create a temporary string "!!!" and remove it, or be clever and do nothing.

The difference is only that int is a "built in type?" that can live in registers, but a string can only live in memory because it does not fit inside a register.

... guess that's it but i'm no expert (some programmers have little interest in programming languages itself).

 

This topic is closed to new replies.

Advertisement