Errors, bugs, questions - page 2418

 
Slava:

Passing a parameter by reference implies that there is a variable allocated in memory.

Constants, on the other hand, are not stored anywhere, but are used directly.

and what prevents you from creating a temporary variable?
 
TheXpert:
And what prevents you from creating a temporary variable?

That's what I do. I don't understand why the developers should do it for me.

 
fxsaber:

That's what I do. Why the developers should do it for me - I don't understand.

So that life gets easier and hello world doesn't turn into a mess? You can also not acknowledge the autogeneration of constructors/operators=.
 
fxsaber:

That's what I do. Why the developers should do it for me - I don't understand.

How nice that the creators of other languages are less categorical about it
 
TheXpert:
How nice that the creators of other languages are less categorical about it

Nothing categorical. I just wouldn't want to waste resources on solving this kind of crap, which is already insufficient to close even bugs in a timely manner. Not to mention new functionality. From announcements to beta releases has become a very long time. And it's even longer before the beta releases are licked. And not without annoying help from forum users.


That's why such topics are perceived as getting to the bottom of bullshit. When so many more serious things aren't done.

 
fxsaber:

That's why topics like this are perceived as getting to the bottom of bullshit. When so many more serious things are not done.

Everyone has their own priorities.

 

Passing a parameter by reference implies that some value will be put into the corresponding variable in order to use that value later, after the function has been called.

How can a temporary variable be used if it is not the result of an expression?

 
Slava:

Passing a parameter by reference implies that some value will be put into the corresponding variable in order to use that value later, after the function has been called.

How can a temporary variable be used if it is not the result of an expression?

Well, it's all subtleties. The pluses have done it, after all. For prvalue, temporary materialization occurs. By the way, you can't do that either

int get();
void fn(const int &);

fn(get()); // error
 
Igor Zakharov:

This is most likely the point at which another character is added (why not all 5 since the start of the test?):

Ask for data for all tools in OnInit, it will be loaded immediately.

 
Slava:

Passing a parameter by reference implies that some value will be put into the corresponding variable in order to use that value later, after the function is called.

How to use a temporary variable, if it is not the result of expression?

What do you think of adding the ability to pass an argument as an r-value to the language? This would immediately solve all the issues and allow you to create universal containers for any type. In particular, the above method would be overloaded for r-value:

void push_back(const T &value);
void push_back(const T&&value);

This is exactly how it is implemented in all STL containers.

And the second plus: it will allow to specify move constructors. Now this is also very lacking, in particular for implementation of smart pointers unique_ptr and other classes, designed to monopoly store some unique resource inside themselves, i.e. usual copy constructors are unacceptable for them.

Reason: