The question is simple.
I have three generic structures like these:
The main structure
Public Structure Pointer(of T) 'Here is where the data type must be constrained
Dim BP As BasePointer
Dim BV As BaseValue(of T)
'Some code
End Structure
The pointer structure
Public Structure BasePointer 'This is a pointer itself, no problem (I think)
'Some code
End Structure
This structure takes the constrained data type by Pointer(of T)
Public Structure BaseValue(Of T)
'Some code
End Structure
As far as I know, structures can be initialized without the new constructor.
The idea is constraint certain value types, but the thing is that they can be, for example, class (as type, not generic container), structure (also as type, not generic container), IntPtr, Char, Integer, float, delegate, enumeration, interface, etc. (as you can see, they are value and reference parameters, I can´t write (of T as class) or (of T as structure), because I don't know what type is going to be passed).
The idea of the program is to create a pointer with a main structure and two secondary structures. One of the secondary structures takes the value of the pointer and the other is a pointer itself.
The operation is as follows:
The main structure captures the type T (here is where I want to make the constraints), and, if the data type is valid, it passes it to the secondary structure that takes the already constrained value, and if not, it discards it (with that data type the pointer is not going to be created). Once the type is passed to the secondary value structure, the pointer is created.
Example:
Dim sample as Pointer(Of ULong)
If the ULong data type is within the constraints, the pointer will be passed to the BV variable (The variable initialized as BaseValue structure), otherwise a message will be displayed.
This, in a class, would have no problem, since it has to be initialized obligatorily. In a class, even if it has a generic type T without constraints, in the same class constructor I create the constraints and got it. But in a structure I don't know how to do it without having to initialize it.
I don't want to make a pointer to all the existing data types, only to those I consider more used (about 20, 25 or so, but of different data types). That's why the data restriction.
Previously I forgot to mention that if this can be done, you can write it in C#, which I more or less understand and I think I could translate it.
Again, thanks in advance.