Errors, bugs, questions - page 1570

 

Need to refine templates (take implementation outside class A {})

template<typename T>
class A { public:
template<typename T2>
        void f1( T2 t2 );
template<typename T2>
        void f2( T2 t2, T tt ) { Print( __FUNCSIG__, " ", typename( this.t ) ); }
template<typename T2>
        void f3( T2 t2, T tt );
        T t;
};
template<typename T>
template<typename T2>
void A::f1( T2 t2 )       { Print( __FUNCSIG__, " ", typename( this.t ) ); } //нормально
template<typename T>
template<typename T2>
void A::f3( T2 t2, T tt ) { Print( __FUNCSIG__, " ", typename( this.t ) ); } // error: 'T' - declaration without type

I can't implement A::f3 outside class A {}.

But inside class A {} you can. Yes, you can... for example, f2(), but the inconvenience lies in the purpose of taking cumbersome functions outside the class A {}. The main thing is that A::f1() can be brought inside class A {} and everything works while A::f3() cannot - the compiler generates an error.

 
Nah, that's a bitch, by the way a typedef is supposed to solve the problem
 
A100:

Need to refine templates (take implementation outside class A {})

I can't implement A::f3 outside class A {}.

But inside class A {} you can. Yes, you can... for example, f2(), but the inconvenience lies in the purpose of taking cumbersome functions outside the class A {}. The main thing is that A::f1() can be brought outside the class A {} and everything works while A::f3() cannot - the compiler generates an error because A::f1() and A::f3() principally do not differ in any way.

This is how it compiles normally.

template<typename T>
class A { public:
template<typename T2>
        void f1( T2 t2 );
template<typename T2,typename T>
        void f2( T2 t2, T tt ) { Print( __FUNCSIG__, " ", typename( this.t ) ); }
template<typename T2,typename T>
        void f3( T2 t2, T tt );
        T t;
};
template<typename T2>
void A::f1( T2 t2 )       { Print( __FUNCSIG__, " ", typename( this.t ) ); } //?????????
template<typename T2,typename T>
void A::f3( T2 t2, T tt ) { Print( __FUNCSIG__, " ", typename( this.t ) ); } //error: 'T' - declaration without type

And f1 and f3 are a bit different

 
Andrey Barinov:

This is how it compiles normally.

It's not - the compiler just assumed there's no OnStart - no problem.

add

void OnStart()
{
        A<long> a;
}
 

Compilation error: internal error #9

Files:
Test114.mq5  3 kb
 

If you change a couple of lines, the error changes to: tree optimization error

But originally (before the simplification) the error was: code generation error

And all ends there - but before it all worked fine.

Files:
Test115.mq5  3 kb
 
A100:

Make a lot of different slim sources in one archive. So that developers could use it before they are going to roll out another buggy build.

Call the archive "lice test". Surely, there are such test variants for different kinds of compilers.

 
Compilation error: code generation error
Files:
Test116.mq5  2 kb
 


Optimization chart stops to be drawn because of incorrect criterion value calculation. Please fix it, as it is very convenient to observe optimization process on the chart.

Appears only on Balance + max RF criteria. // At least in my (so far small) practice.

// Only graph breaks, optimization is successful.

----------- UPD

Проявляется только на критерии Balance + max RF.

I was wrong.


 

Different behaviour of & and GetPointer

class A {};
class B {
        A *f() const { return GetPointer( a ); } //не генерирует ошибки
        A *g() const { return &a; }              //ошибка: 'return' - cannot convert from const pointer to nonconst pointer
        A a;
};