Skip to content

Instantly share code, notes, and snippets.

@yoh2
Last active January 26, 2018 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoh2/42b375f41978c7486f958447fa3e5f19 to your computer and use it in GitHub Desktop.
Save yoh2/42b375f41978c7486f958447fa3e5f19 to your computer and use it in GitHub Desktop.
a == 1 && a == 2 && a == 3 を真に。
#include <iostream>
struct A
{
constexpr bool operator==(int) const
{
return true;
}
};
int main()
{
A a;
std::cout << std::boolalpha << (a == 1 && a == 2 && a == 3) << std::endl;
}
public class Hoge
{
public static void Main(string[] args)
{
var a = new Hoge();
System.Console.WriteLine("{0}", a == 1 && a == 2 && a == 3);
}
public static bool operator==(Hoge hoge, int n)
{
return true;
}
public static bool operator!=(Hoge hoge, int n)
{
return false;
}
}
import std.stdio;
struct A
{
public bool opEquals(int n) const
{
return true;
}
}
void main()
{
A a;
writeln(a == 1 && a == 2 && a == 3);
}
data A = A deriving Eq
instance Num A where
_ + _ = A
_ * _ = A
negate = id
abs = id
signum = id
fromInteger _ = A
main :: IO ()
main = let a = A in print $ a == 1 && a == 2 && a == 3
struct A;
impl PartialEq<i32> for A {
fn eq(&self, _: &i32) -> bool {
true
}
}
fn main() {
let a = A;
println!("{}", a == 1 && a == 2 && a == 3);
}
main :: IO ()
main = let a = () in a == 1 && a == 2 && a == 3
where _ == _ = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment