c++ - How to determine type compatibility for a mixin template of a non-polymorphic type -
If I have a mix that is defined ...
template & Lt; Class T & gt; Classroom Mixin: Public T {// Mixing Methods and Members}; ... and declare it with a non-categorized square t ...
mixin < NonPoly & gt; Mixin; .. and then it has a base class indicator ...
non-polly * non-polip = and mixin; ... can I make sure later that the non-yellowpeeter is pointing to a mixin type?
Dynamic_cast Mixine * & gt; (Non-POLPT) is not compiled above because the base class is non-polymorphous.
I noticed that there are some specialty classes in Boost that can help, but I hope that is a simple solution.
I think you're looking at the wrong requirements. You do not need to do any casting here, but you may need some restructuring of your code. If you have a relation of class A, which makes a mixer and B uses non-poli, then pass B to the nanopoly pointers and use the mixin directly in A. There should be no reason to leave the information of type A to get it back again If there are more classes, separate those people who know the mixin and those who know the non-husband, and this one Is the only relationship
And it is very likely that if it is in the first place, then the mixing design is not an appropriate perspective. Many times, the use of blends is done when simple prevention is required. In my example with the above A and B, you may have a mixine class
template and then pass the object when it should be turned on or even more general, if you are just passing a tee third party library, then you do not need a mixer at all is. Control can not be the best. The best way to keep encapsulation is to always write a file-scope algorithm, when you can manipulate Type T through the public interface and public third party operating system.
If you can tell that why you feel you need to lose type of information and recover later, we may be able to show more clearly how you own You can reorganize so that there is no need to do this, but such information never leaves a runtime (since you are looking to insert - your question means serial or something Minister is not getting), I can assure you that some of the design where the type of information that went not lost in the first place.
Comments
Post a Comment