title: Subclass a Struct or Similar
body: <p>I understand how structs and classes (and protocols) work on the basic level. I have a rather common situation:</p>
  
  <p>I need to have generic value types with operators which really must copy on assignment.
  These types have complex structure and I would like to be able to specialise by subclassing otherwise there will be copied code everywhere and it will be poor programming.</p>
  
  <p>I have tried protocols and extensions but then because the protocol wasn't generic I was unable to define the (generic) operators I wanted.
  If I use classes I will not copy on assignment.</p>
  
  <p>Today's example is I have Matrix, and SquareMatrix under that with specific square matrix functions. There are operators and the matrices can be populated by anything conforming to my ring protocol. I tried defining almost all the functionality in a protocol with associated type, and an extension.</p>
  
  <p>Edit: I am really wondering what I should be coding. In the matrix situation I need to be able to pass a square matrix as any other, so subclassing is the only option? Maybe I'm wrong. The main issue is when I have to write a function which talks about internal values, I have to know the generic type argument to do anything useful. For example when defining addition, I have to create a new matrix and declare its generic type, but where do I get that from when I only know something is a (nongeneric) protocol - it's real type is generic but despite the protocol having this associated type, I have no way of getting it out.</p>
  
  <p><strong>Solution</strong> thanks to alexander momchliov. Essentially more work was needed to move code into the protocol extension fully and use 'Self' for all the relevant types. In the extension the compiler was happy with what the generic types were.</p>
  
  <p>The code was private, I am sorry I was unable to paste any during this question. Thanks for your patience and help.</p>