-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
737 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace Hosihikari.NativeInterop.Unmanaged; | ||
|
||
public interface ICppInstanceValueType<TSelf> | ||
where TSelf : unmanaged | ||
{ | ||
} | ||
|
||
public interface ICopyableCppInstanceValueType<TSelf> : ICppInstanceValueType<TSelf> | ||
where TSelf : unmanaged | ||
{ | ||
TSelf Copy(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Hosihikari.NativeInterop.Unmanaged.STL.Interface; | ||
|
||
internal interface IStdIterable<TIterator, T> | ||
where TIterator : unmanaged, IStdIterator<TIterator, T> | ||
where T : unmanaged | ||
{ | ||
public TIterator Begin(); | ||
public TIterator End(); | ||
|
||
public ReverseIterator<TIterator, T> RBegin(); | ||
|
||
public ReverseIterator<TIterator, T> REnd(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
| ||
using System.Numerics; | ||
|
||
namespace Hosihikari.NativeInterop.Unmanaged.STL.Interface; | ||
|
||
public interface IStdIterator<TIterator, T> : | ||
IEqualityOperators<TIterator, TIterator, bool>, | ||
IIncrementOperators<TIterator>, | ||
IDecrementOperators<TIterator> | ||
where TIterator : unmanaged, IStdIterator<TIterator, T> | ||
where T : unmanaged | ||
{ | ||
public ref T Target { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Hosihikari.NativeInterop.Unmanaged.STL.Interface; | ||
using System.Numerics; | ||
|
||
namespace Hosihikari.NativeInterop.Unmanaged.STL; | ||
|
||
public struct ReverseIterator<TIterator, T>(TIterator current) : | ||
IStdIterator<ReverseIterator<TIterator, T>, T>, | ||
IIncrementOperators<ReverseIterator<TIterator, T>>, | ||
IDecrementOperators<ReverseIterator<TIterator, T>>, | ||
IEqualityOperators<ReverseIterator<TIterator, T>, ReverseIterator<TIterator, T>, bool> | ||
where T : unmanaged | ||
where TIterator : | ||
unmanaged, | ||
IStdIterator<TIterator, T>, | ||
IIncrementOperators<TIterator>, | ||
IDecrementOperators<TIterator>, | ||
IEqualityOperators<TIterator, TIterator, bool> | ||
{ | ||
private TIterator current = current; | ||
|
||
public readonly TIterator Base | ||
{ | ||
get => current; | ||
} | ||
|
||
public ref T Target => ref current.Target; | ||
|
||
public readonly override bool Equals(object? obj) | ||
{ | ||
return obj is ReverseIterator<TIterator, T> iterator && | ||
EqualityComparer<TIterator>.Default.Equals(current, iterator.current); | ||
} | ||
|
||
public readonly override int GetHashCode() | ||
{ | ||
return HashCode.Combine(current); | ||
} | ||
|
||
public static ReverseIterator<TIterator, T> operator ++(ReverseIterator<TIterator, T> value) => new(--value.current); | ||
|
||
public static ReverseIterator<TIterator, T> operator --(ReverseIterator<TIterator, T> value) => new(++value.current); | ||
|
||
public static bool operator ==(ReverseIterator<TIterator, T> left, ReverseIterator<TIterator, T> right) => left.current == right.current; | ||
|
||
public static bool operator !=(ReverseIterator<TIterator, T> left, ReverseIterator<TIterator, T> right) => left.current != right.current; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Numerics; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace Hosihikari.NativeInterop.Unmanaged.STL; | ||
|
||
|
||
public readonly ref struct StdLess<T> | ||
where T : unmanaged, IComparisonOperators<T, T, bool> | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static bool Compare(in T left, in T right) => left < right; | ||
} | ||
|
||
public readonly ref struct StdLess | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static bool Compare<T>(in T left, in T right) | ||
where T : unmanaged, IComparisonOperators<T, T, bool> | ||
=> left < right; | ||
} |
Oops, something went wrong.