struct inheritance need?

Weed resume755 at mail.ru
Wed Dec 24 01:33:43 PST 2008


Weed пишет:
> Kagamin пишет:
>> Weed Wrote:
>>
>>>> I'd prefer run-time checks, though
>>>> templates can be used for sure.
>>> This problem would help solve the availability of inheritance for 
>>> structs or compile-time creation of class instances.
>>
>> And I see no problem. Absence of compile-time object creation doesn't 
>> prevent you from using templates.
> 
> The problem is not in use templates.
> 
> Templates are implementing some of the functionality of 2 types of 
> structures matrices (normal and dynamic). But the structures do not 
> inherit, then to add functionality matrix to other entities ( "pixel", 
> "image" etc) sites will have their list in a template return type.
> 
> For example:
> http://www.dsource.org/projects/openmeshd/browser/trunk/LinAlg/linalg/MatrixT.d 
> 
> 
> see template MultReturnType(ArgT)
> 
> It contain list of all types (MatrixT and VectorT) for return. Will it 
> add types of "image" and "pixel" and still others if needed. This is as 
> good as manually implement a new object model.
> 
> It is not necessary to suggest to wrap up "pixel" in a class - then it 
> too cannot be initialized in a compile time.

In fact, the minimum number of matrices 3:
dynamic
fixed-size
fixed-size static

The last 2 are different way of storing components - "fixed-size static" 
  has dynamic array (because compile-time assignment is now does not 
assign anything to static array) and "fixed-size" it with a static array 
with size calculated in the template.


I will be happy if someone tells a mistake in the design of my idea :)


More information about the Digitalmars-d-learn mailing list