Errors, bugs, questions - page 1730

 
Ilyas:
That's right, here in typing, T = A *

Then there is a compilation error here

template<typename T>
void f1( const T  const & a[] ) {} //error: 'const' - unexpected token
class A {};
void f2( const A* const & a[] ) {}
class B {
        void g1() const { f1( a ); }
        void g2() const { f2( a ); }
        A *a[];
};
 
Sergei Vladimirov:
Exactly. I read all these claims and still can't understand where the problem is. Are you going to store these files on a floppy disk?


Does it wear out your disk when you save a 100K file instead of a 50K one? (Isn't that funny to you? )

Is it normal that because of a single copyright character (which in principle is international and is in all encodings, even though its code is greater than 127) the file size is doubled without any sense? Isn't it clever? Why bloat files by 2 times without any need?

It's not just the size that's the problem, it's also the contextual search. As long as the files are in ASCII, you can use many third-party programs, including file managers, to search for files using the context string. I use this almost every day. The native MQ editor is as zilch in this regard as in many other obvious coding issues. Once we've got unicode, context search has two problems: not all programs can or want to do that, and for those who can, we get point 2 - slowness.

Of course, some people find it easier to buy a faster computer in addition to the hard drive than to think or at least learn from other products how user-friendly and efficient software should be.

 
A100:

Then there is a compilation error here

In C++ too there is ambiguity of the type: const T const

But there is a way out - move const to the right

template<typename T>
void f1(  T         const & a[] ) {} //error: 'const' - unexpected token
class A {};
void f2(  A const * const & a[] ) {} //нормально
class B {
        void g1() const { f1( a ); } //error: 'f1' - cannot to apply function template
        void g2() const { f2( a ); } //нормально
        A *a[];
};
C++ compiles without errors (considering the syntax difference)
 
A100:

In C++ too, there is ambiguity of the type: const T const

But there is a way out - move const to the right

C++ compiles without errors (given the syntax difference)

But logically it's strange when "const A" and "A const" mean the same thing.

Perhaps"Aconst*" is a constant pointer to a non-const object.

This seems to be the case. Because such a construct exists.

class A {};
void f( const A const * const & a[] ) {}

You cannot change the pointer, you cannot change by reference and you cannot change the object(s).

From the viewpoint of getting fast code, could such a construct give the compiler a proper hint?

 
Stanislav Korotky:

Is it normal that a single copyright character (which in principle is international and is present in all encodings, despite the fact that its code is bigger than 127) causes the file size to increase by 2 times...

Yes. For all intents and purposes, I don't see the point in saving on matches.
 
It's interesting that in this construction
class A {};
void f( const A const * & a[] ) {}

You can't change the elements, but you can change the size of the array.

Funny, it turns out that methods can look like this

class A {};
class B
{
  const A const * Method( const A const * const & a[] ) const
  {
    return(a[0]);
  }
};
 
fxsaber:

It is possible that"Aconst*" is a constant pointer not to a constant object.

If not a pattern, then "A const *" equals "const A *", and if a pattern, by that situation (in C++ )
 
A100:
If not a pattern, then "A const *" equals "const A *", and if a pattern, then by situation
So there should be no equivalence. MQL considers it equivalent, however
class A
{
public:
  int i;
};

void f( A const * & a[] )
{
  a[0].i = 1; // 'i' - constant cannot be modified
}
In my opinion, there is an error here. Because it's an array of constant pointers (const *) being passed, not an array of pointers to constant objects(const A).
 
A100:
Specifically this - fixed in the future https://www.mql5.com/ru/forum/1111/page1749#comment_2892563
Then there should be no equivalence in your statement
A100:
If not a pattern, then "A const *" equals "const A *", and if a pattern - by that situation (in C++ )
 
fxsaber:
It's interesting that in a design like this...
class A {};
void f( const A const * & a[] ) {}

elements cannot be changed, but the size of the array can be changed.

Really? That's a bummer, it shouldn't be like that.
Reason: