- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
#include <stdio.h>
#include <string>
const struct FooAgeProperty {} age;
const struct FooNameProperty {} name;
template <typename T>
struct FooPropertyAssignment {
FooPropertyAssignment(T* prop): prop(prop) { }
T* prop;
};
struct years {
int i;
years& operator=(FooPropertyAssignment<int> fpa) {
*fpa.prop = i;
return *this;
}
};
struct nam {
std::string s;
nam& operator=(FooPropertyAssignment<std::string> fpa) {
*fpa.prop = s;
return *this;
}
};
years operator""years(unsigned long long value) {
return { (int)value };
}
nam operator""_(const char* value, size_t) {
return { value };
}
struct NegativeFoo {
NegativeFoo(int* age, std::string* name): age(age), name(name) {}
int* age;
std::string* name;
};
FooPropertyAssignment<int> operator<(FooAgeProperty fap, NegativeFoo nfoo) {
return FooPropertyAssignment<int>(nfoo.age);
}
FooPropertyAssignment<std::string> operator<(FooNameProperty fnp, NegativeFoo nfoo) {
return FooPropertyAssignment<std::string>(nfoo.name);
}
struct Foo;
Foo* nasty_global_variable;
struct Foo {
Foo() {
nasty_global_variable = this;
}
NegativeFoo operator-() {
return NegativeFoo(&age, &name);
}
int age;
std::string name;
};
struct to_string {
struct foo {
foo(int (*)(const char*, ...)) {
printf(".old years %d am I and %s is name My\n", nasty_global_variable->age, nasty_global_variable->name.c_str());
}
};
};
int main() {
Foo foo;
5years = age<-foo;
"Billy"_ = name<-foo;
(to_string::foo)printf;
}
https://www.reddit.com/r/ProgrammerHumor/comments/acv2og/just_wrote_my_first_program_in_c/
Steve_Brown 06.01.2019 13:39 # +1
ctrl-meta-f 07.01.2019 15:47 # 0
HoBorogHuu_nemyx 07.01.2019 16:18 # 0
Именно поэтому я за "R".
ctrl-meta-f 07.01.2019 16:24 # 0