Closed ufcpp closed 3 years ago
開幕から Java とか C++ な話にそれまくり。
C# にも int template ほしいという話あり…
GaloisField<_2> x;
interface INum { int Value { get; } }
struct _0 : INum { public int Value => 0; }
struct _1 : INum { public int Value => 1; }
struct _2 : INum { public int Value => 2; }
struct _3 : INum { public int Value => 3; }
struct _4 : INum { public int Value => 4; }
struct _5 : INum { public int Value => 5; }
struct _6 : INum { public int Value => 6; }
struct _7 : INum { public int Value => 7; }
struct _8 : INum { public int Value => 8; }
struct GaloisField<T>
where T : INum
{
}
C# にも ownership モデルほしいんだけど…
一応、non-copyable なら…
https://ufcpp.net/blog/2017/12/noncopyable/
最近は公式に使ってる: https://github.com/dotnet/roslyn-analyzers/pull/3420
using System;
var x = new X();
using (x) { } // x のコピーかかってる
Console.WriteLine(x.Value); // 0
struct X : IDisposable
{
public int Value;
public void Dispose()
{
++Value;
}
}
using System;
var x = new X();
using (x) { } // x のコピーかかってる
Console.WriteLine(x.Value); // 0
ref struct X
{
public int Value;
public void Dispose()
{
++Value;
}
}
関数ポインターの記事書くの、実例がまだ少なくて困ってる話
配信URL: https://www.youtube.com/watch?v=fZSL9Dc_8JY
連休中に書いてた記事の話と、「そろそろ休みボケ解消しようか」を目的とした配信。
GW 中に一応に レコード型 の話書いた。
C# 9.0 がらみの残タスク: https://github.com/ufcpp/UfcppSample/issues/297 残りは nint と関数ポインターだけのはず。
関数ポインター… たぶん一番使われるのはクロスプラットフォームの Native Interop (要は Xamarin との統合)と思われるものの、その作業が .NET 6 マイルストーンなので、利用箇所が少なすぎて紹介しづらい…