1

Topic: Templates, with ++ 11. Whether It is possible such to make?

There is a template-class, from a variable of a class of parameter, about the such:

template <class T> class C1
{
T m_t;
}

This template has a method which depending on different things, calls different methods of class , addressing to m_t
In the code I declare a variable, setting certain other class as argument:

C1 <C2> c;

Class C2 - functional, does any things.
Class 1 - interface, to it comes on an input a line, he  and understands it, as with what parameters it is necessary to call from class T (i.e. C2)
Now I want to make class 3,  from 2 and to add there a functional.
And as I want to add variants of analysis of an input line in 1 i.e. that he "understood" more variants of an input line, for class 3.
Thus I want to begin with class 1, i.e. to make at first logic, to set commands which are to be processed. And so, I should call new functions from m_t. But then the code will not be compiled, because at 2 (3) there are no still such functions.
Question: it is possible to make somehow so that calls of missing functions were not compiled? It would be possible to make a class-cap In where to define all methods caused from 1 as empty, and from it  2. But then it is necessary to support 2 classes (1 and). Therefore it would be desirable that at a spelling in code 1 m_t. SomeNewMethod3 (), in the absence of SomeNewMethod3 in 2,  an empty method. It something of type as in VB: if I write:

AND: = "Some"

That And automatically melts in the line. And if I declare it earlier is not present.
In general, sounds , but suddenly there are what decisions? Sense it that would be desirable to make one interface class for all possible variants C2, C3, C4 etc. with a different dial-up of a functional. In case of absence to produce outside "a method it is not supported"
I know that in templates there is such piece: if the method is not caused anywhere - it is not generated, even if remaining methods (caused) were generated. But here a reverse situation smile

2

Re: Templates, with ++ 11. Whether It is possible such to make?

CEMb wrote:

the Question: it is possible to make somehow so that calls of missing functions were not compiled?

And how then you learn, what it is time to you to implement the new method, which else are not present?
The compiler keeps silent. In ? It looks as the bad decision smile
I hope, language of the such does not allow smile

3

Re: Templates, with ++ 11. Whether It is possible such to make?

http://stackoverflow.com/questions/8737 … #16824239?

4

Re: Templates, with ++ 11. Whether It is possible such to make?

alex_k wrote:

And how then you learn, what to you is time to implement the new method, which else is not present?

When from the console it I will launch, it produces an error. If it will be necessary to me, I will go and I implement it. Such there was an idea. I.e. designing from usage, so to say.

alex_k wrote:

I Hope, language of the such does not allow smile

Well, looks, as the bad decision, agrees. Simply it would be desirable to untie a functional of class 2 from 1. Roughly speaking, it would be desirable something such: 1: "count to me integral", 2: I "do not understand", 1: " 2 on 2", 2: "4". I.e. in 1 I can "ask" anything you like from the console, but the decision, to fulfill or not, remains for 2.

alexy_black wrote:

  for one method

wrote:

And then to do refactoring of method names, not?

it will be inconvenient to use such piece a little, but it is necessary to think, it can is somehow possible to make more conveniently.

5

Re: Templates, with ++ 11. Whether It is possible such to make?

wrote:

In Delphi such by the way easily becomes by means of RTTI. For Si* I do not know, recently started to study.

In pluses too is RTTI. And how by means of RTTI it to make?

6

Re: Templates, with ++ 11. Whether It is possible such to make?

CEMb wrote:

it is passed...
In pluses too is RTTI. And how by means of RTTI it to make?

Any Actor-Model  on a C ++ does it. CAF, Theron etc. Judging by your initial question is that that you search.

7

Re: Templates, with ++ 11. Whether It is possible such to make?

CEMb wrote:

it is passed...
When you do something on templates, it can  not add the code in resultant files. Whether the methods resulted there simply give to the compiler the answer to a question  a method in template parameter, they will not add really executable code.

Posts [ 7 ]

Pages 1

You must login or register to post a reply