1

Topic: Pointers and generalizations

I transport the code from a C ++/CLI which uses templates and pointers in C#. However C# for the present does not allow to use pointers with generalizations. struct A <T> {} A <int> * p;//:( One of variants it through Marshal. PtrToStructure that leads to superfluous copies, and ' struct ' in addition it is necessary to replace on ' class'. Other decision through generation in a type.tt a file. There are other interesting methods to solve this task?

2

Re: Pointers and generalizations

Hello, _NN _, you wrote: _NN> I Transport the code from a C ++/CLI which uses templates and pointers in C#. _NN> However C# for the present does not allow to use pointers with generalizations. If  on , what for it is necessary to leave pointers? Or again - for speed?

3

Re: Pointers and generalizations

Hello, Nikolay_Ch, you wrote: N_C> If  on , what for it is necessary to leave pointers? Or again - for speed? Yes. In this place any copying will be to the detriment.

4

Re: Pointers and generalizations

Hello, _NN _, you wrote: N_C>> If  on , what for it is necessary to leave pointers? Or again - for speed? _NN> yes. _NN> In this place any copying will be to the detriment. ref return from c# 7 do not approach?

5

Re: Pointers and generalizations

Hello, Sinix, you wrote: S> ref return from c# 7 do not approach? Not so. At me function invocation from  the code where I receive the simple pointer. Further I process it on a miscellaneous depending on a platform and title. It seems that nevertheless, the least risky in a C ++ the code will replace.NET types with a C ++ th and to organize  in C#. By the way, as is better to span in C# type like hash_map <wstring, struct Data {uint64_t x; uint64_t y;}> (in original Dictionary <String, Data>)?

6

Re: Pointers and generalizations

Hello, _NN _, you wrote: __ NN> It seems that nevertheless, the least risky in a C ++ the code will replace.NET types with a C ++ th and to organize  in C#. If it is necessary  __ productivity I would not suffer and would do all in . The Overhead charge gloomy will be, especially with non-blittable. Old guidelines about the same advise. _NN> by the way as is better to span in C# type like hash_map <wstring, struct Data {uint64_t x; uint64_t y;}> (in original Dictionary <String, Data>)? In any way . Or c-style (structures and arrays), or com-interop. Well, i.e. it is possible  the pointer on the dictionary and to make  methods for  values of the dictionary, but somehow it is sad absolutely. But I that still  in , can be mistaken.

7

Re: Pointers and generalizations

Hello, Sinix, you wrote: S> Hello, _NN _, you wrote: __ NN>> It seems that nevertheless, the least risky in a C ++ the code will replace.NET types with a C ++ th and to organize  in C#. S> If it is necessary  __ productivity I would not suffer and would do all in . The Overhead charge gloomy will be, especially with non-blittable. S> Old guidelines about the same advise. Completely  in any way and it would not be desirable here if there were templates in C# there would be no choice problems.