OOP, templates and macros in mql5, subtleties and uses - page 13

 

Just yesterday we were discussing about this bug with abstract methods, but today I ran into the same bug in my code ) I used to have non-abstract virtual method in base class, so I refer to it from inherited classes, then I decided to make the method abstract, but compiler didn't inform me that it was no longer referbable. As a result, the recursion error was the nastiest and hardest to detect, and I killed a lot of time. Now I think that feature with default abstract method body will be very useful here, at least until this bug is fixed.

 
Alexey Navoykov:

Yeah, to make it as convenient as possible to assign flies to cutlets, and no one even blinked an eye )

If the assignment process is bringing flies to cutlets (or produces an error if it is not possible), then there is nothing wrong with it.

Alexey Navoykov:

1.Well, then it's just class A. Why declare a pattern if its parameter has no meaning whatsoever to do with the behavior of the class?

2) That's too much trouble. Transferring the type control to the stage of execution... Your codes will take years to debug

1. "Just class A" cannot contain a field of an arbitrary type without its (class) parametrization. And without those dancing around, which I have described, it's impossible to make uniform handling of a class parameter by reference and by value.

2. You already have it like a mantra - in this case absolutely unambiguous record guaranteeing that F is T, that is as if there was no record of the second template. but no. Again "I'll spend years debugging" ))))))

 
Ilya Malev:

1. "Just class A" cannot contain a field of arbitrary type without its (class) parameterization. And without those tinkering, which I described, it is impossible to make uniform handling of class parameter by reference and by value.

2. You already have it like a mantra - in this case absolutely unambiguous record guaranteeing that F is T, that is as if there was no record of the second template. but no. Again "I'll spend years debugging later" ))))))

And why are you replying in this thread? Code in one place, discussion in another... )

1. Yes, everything can be done in a human way, and almost without dancing:

struct __A
{
  template<typename T>
  void f(T&) { }  // Сюда структуры и классы
};

struct A : __A
{
  template<typename T>  
  void f(T) { }  // Сюда простые типы и указатели
};

2. That's not what I was talking about, but never mind.

 
Alexey Navoykov:

Why are you answering in this thread? Code in one place, discussion in another... )

1. Yes everything can be done in a human way, and almost without dancing:

2. There was something else there, but it's not the point.

It's not like you're a moderator yet, to determine in which thread what's more appropriate. And the moderators have already made it clear that discussions of features should not be in the features branch themselves, but in a separate branch, i.e. here.

In your description, it is not clear at all how to refer uniformly to a class method by reference and by a T-type value. I do not know what you mean by it, but it was exactly what I meant there.

 
Ilya Malev:

It's not like you're a moderator yet, to determine which threads are more appropriate. And moderators have already made it clear that the discussion of features should not be held in the branch of features, and in a separate thread, ie here.

So if a moderator wants to move it, that's one thing, but why create the confusion yourself? I, for example, have no desire to run through the threads.

 
Alexey Navoykov:

So if a moderator wants to move it, that's one thing, but why create the confusion yourself? I, for example, have no desire to run through the threads.

If you know a moderator would do something like this it's always better to do it yourself rather than wait for a moderator to do it. However, discussing moderators' actions is not one of the moderators' favourite menus either, so it would be better if we stopped it.

 
Alexey Navoykov:
Сюда простые типы и указатели

For pointers, by the way, it is logical to make a separate method with the T* argument, because there is definitely no confusion, and the benefit is most often that handling pointers is different from regular types (validity check, deletion, etc.)

 
Alexey Navoykov:

Code in one place, discussion in another

Here is the code:

template<typename T>
class A
 {
public:
  A* operator<<(T&p){ Print("<< &",typename(T)); return &this; }
  template<typename F>
  A* operator<<(F p){ Print("<< ",typename(F)); return &this; }
 };

Actually there is another solution besides this entry: list by name all simple types passed by value and then write template method with &, then there will be no error either. This option is suitable for classes without intrinsic parameterization

 
Ilya Malev:

If you realise that a moderator would probably do exactly that - it's always better to do it yourself, rather than waiting for a moderator to do it. However, discussing the actions of moderators is not a favourite menu of moderators either, so it would be better if we stopped it.

A moderator would certainly not break up the discussion into different threads. You're probably so eager to even ban yourself,"without waiting for a moderator to do it" ))
 
Ilya Malev:

If you realise that a moderator would probably do exactly that - it's always better to do it yourself, rather than waiting for a moderator to do it. However, discussing the actions of moderators is not a favourite menu of moderators either, so it would be better if we stopped it.

1. It would be better to start talking about something right away, where this "something" is located, rather than thinking about how the moderator would do it. Otherwise, everything really got blurred into two threads and now, even if a moderator decides that the discussion should be there or there, it is quite a laborious task to move the discussion normally, preserving the order and meaning of the posts.

2 Discussing the actions of a moderator is not every sneeze... It's not every sneeze, but if you want to challenge him publicly, make him clean up or pacify those who have gone wild. And if you have an opinion, who forbids you to express it? Maybe your opinion is a very rational suggestion, but you are afraid to say it, so as not to fall under the moderator's unloved menu? So that's bullshit :)