Alf said:
So what? Kevin, not the OP, made a statement about _polymorphic_
types. That statement was incorrect and irrelevant.
That part of the statement was incorrect. But then again you can see that
statement in quite a few places and IMO what other possible uses I have seen
in the standard there you need no cast.
Yep. But not very relevant to anything... ;-)
Did you note the example code?
Did you note my (cut out by you) statement about (non existing) template
functions and the possibility to specialize function templates?
Oh yes he can. I already gave explicit code for that. It's not the
easiest way to do it, though.
Not and IMHO it is absolutely unnecessary. You create a template code bloat
to support an absolutely wrong approach to programming (note to the reader:
not all compilers will just forget about instantiated templates, even if
they are inline).
The solution works, but it is IMHO way overcomplicated.
The message was, quoting: "dynamic_cast is only for polymorphic
types".
And that's simply not true.
The full message was: ", not doubles, floats, etc;" I think it is an
important part of it. And I believe that Kevin did not think that you will
come up with a two-pairs-of-template solution, out of which each will be
instantianed for all types ever used in that original function template as
well as for all the checked types - even if they never get used.
Hm. That means you didn't previously understand that a dynamic_cast,
like the code I presented, is a technically correct solution to the
OP's problem?
I understand that code. it works. It is also good for an obfuscated code
contest.
IMHO it is way to overcomplicated. The OP needs to factor out
that type dependent part of his code into another function template (sort of
template method with templates way) and specialize this little piece for the
special ones, while giving a generic solution to all the others.
In the example code above, 'myArg' can be of a fundamental type.
The usage example checks for fundamental type 'float'.
Try it out if you don't believe it... ;-)
I believe it. I just do not think that this is a solution to be considered.
That is correct, but so what? You're trolling.
Alf, you are trolling and flaming. Stop the nonsense.
Perhaps. I'm not sure. I think at least my statement about compile
time evaluation was not properly qualified... :-(
As I saw in the standard it makes no statement about this issue at the
dynamic_cast pages. I am not sure if the standard ever says anything like
that.
Much better if you had raised that issue, then I could have said,
whoops, instead of pointing out inconsistencies and such.
Ahha. How is this 70ties thing? Whatever.
The code above is an actual implementation.
Compiled with VC7 and g++ 3.2.3.
Yep. It is. Who do you think would maintain a code like that? if (are you
crazy) handlecrazy; else if (are you flower) smellit(); else if (are you
hot) doher();...
Heh, young man indeed. Thank you. Now if you could just stop
trolling.
Go to hell Alf. And I say this with all the love in my hearth.
Mail away... At least I'll answer "no time" if it seems too much.
Oh. How nice of you. I will see if I have time to mail you. For those who
don't get it (as you seem): I have offered you a possible cooperation in
case you want to stop the pissing contest. I do not see that from your
post.
I was not humiliating myself but giving you a this opportunity as a token of
appreciation and a way to end this rather awkward tension I have experienced
from yout tone. Now as I see you do not really give me any kind of respect
here and do not stop your pissing contest and do nto stop repeating that I
troll. I do *not* appreciate this. So I think I will just stick with my
original reviewer. He has also promised that he will help if he has time.
He wrote a book about C++. And he has another important connection to the
language... Anyway: have fun. I do no really get it why do you keep
kicking everyone around here today, but I think I will chose not to
experience your attitude anymore.