Enhanced C#
Language of your choice: library documentation

Documentation moved to ecsharp.net

GitHub doesn't support HTTP redirects, so you'll be redirected in 3 seconds.

 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Public static fields | Static Public Member Functions | List of all members
Loyc.ValueComparer< T > Class Template Reference

You'd think the .NET framework would have a built-in method–even a CIL opcode–to bitwise-compare two values. Not supporting bitwise compare is, in my opinion, one of several mind-bogglingly dumb decisions in the CLR. Instead, all you can do is call ValueComparer.Default.Equals(a, b). More...


Source file:

Remarks

You'd think the .NET framework would have a built-in method–even a CIL opcode–to bitwise-compare two values. Not supporting bitwise compare is, in my opinion, one of several mind-bogglingly dumb decisions in the CLR. Instead, all you can do is call ValueComparer.Default.Equals(a, b).

The Default.Equals method is a virtual function call, but as far as I know, in generic code there is no way to avoid this while supporting any type T.

If T is a reference type, it compares the two references using ReferenceComparer. If T is a struct then this class does not currently perform a bitwise comparison, as it just uses EqualityComparer(T).Default. In the future somebody should write a fast "unsafe" bitwise comparer for value types that do not implement IEquatable, because the default implementation of Equals is documented to use reflection, so we can expect that it is extremely slow.

Public static fields

static readonly
EqualityComparer< T > 
Default = GetComparer()
 

Static Public Member Functions

static bool Equals (T a, T b)