Errors, bugs, questions - page 2719

 
fxsaber:

Constructor only because you can't initialise a const field without it. Structure or class - doesn't make any difference. The main thing is to have an object.

It's up to you.


 
Vict:

It's up to you.

I didn't think const fields were contrary to general practice.

 
Information on bugs in the call priorities of overloaded template functionshas been updated and supplemented.
 
fxsaber:

I didn't think const fields were at odds with general practice.

No )), I just thought it should be right on the structures. Why do we need any crutches then? It's quite elegant, make an array, loop around and do set(). If there's an error in the logic (repeated call somewhere), you'll get a crash.

class A {
    int a;
public:
    A() : a(INT_MAX) {}
    void set(int aval) {if (a != INT_MAX) abort(); a = aval;}
    int get() {return a;}
};
 
Vict:

I don't think it's worth sticking your nose in someone else's swamp.

 
Sergey Dzyublik:

I don't think it's worth sticking your nose in someone else's swamp.

Junkie? fxsaber asked for advice, I told him.

 
fxsaber:

In my opinion, it is logical to write const for fields that will never (and should never) be changed after creation.

No. They make const fields in very rare cases. And not for simple types.

 
Vict:

A junkie? fxsaber asked for advice, I answered.

Keep it simple and you'll be approached...

 
Koldun Zloy:

No. Constant fields are made in very rare cases. And not for simple types.

A simple example. You need an array of MAUs with preset periods.

Each one of them is an object of one type. It is clear that an object of one type is uniquely set by its period. That's why it would be logical to make it const.


Other languages simply make an array of pointers. There is no such freedom in MQL.

 
Koldun Zloy:

No. Constant fields are made in very rare cases. And not for simple types.

Do you know how the MQL optimizer and compiler are set up?
How can you be so sure that const fields of simple types are not used for this purpose?