An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

nuget.org : consttypeargs.nuints

Builds on types of the ConstTypeArgs.Core library to provide const type arguments that allow you to use type parameters to pass nuint (UIntPtr) values to generics at compile-time. This provides an analog to type specialization in C++, and can be used for scenarios such as: * Static configuration, * Eliminating unnecessary instance constructors, * "Passing" values to type initializers, * And more. Here's a simple demonstration: using ConstTypeArgs.Nuints; public class Foo<TSize> where TSize : K_Nuint { public static readonly int[] FooArray = new int[TSize.Value]; static Foo() { Console.WriteLine($"Integer array size is {FooArray.Length}"); } } // Elsewhere var foo = new Foo<_3>(); // Outputs "Integer array size is 3" foo = new Foo<_16>(); // Outputs "Integer array size is 16" The following shows how a new nuint const type argument could be defined. public readonly struct _32 : K_Nuint<_32> { public static nuint Value => 32; } You can also create new domain-specific nuint const type arguments like so: public sealed class DefaultInitialCollectionSize : K_Nuint<_32>;

Registry - Source - JSON
purl: pkg:nuget/consttypeargs.nuints
Keywords: constants , const-type-args , generics , static-abstract-interface-members , nuint , csharp , dotnet
License: MIT
Latest release: about 1 year ago
First release: about 1 year ago
Downloads: 172 total
Stars: 2 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 17 days ago

    Loading...
    Readme
    Loading...