Skip to content

Instantly share code, notes, and snippets.

View onqtam's full-sized avatar
:shipit:

Viktor Kirilov onqtam

:shipit:
View GitHub Profile
// use %ERRORLEVEL% to see result of program
#include <iostream>
#include <memory>
using namespace std;
struct A1 {};
struct A2 {};
struct A3 {};
#include <iostream>
using namespace std;
struct A {
int a;
};
struct B {
int b;
};
// use %ERRORLEVEL% to get the result
#include <iostream>
#include <vector>
#include <list>
#include <map>
using namespace std;
struct A {
A(int in = 5) : a(in) { cout << "ctor!" << endl; }
@onqtam
onqtam / cat.cpp
Last active August 29, 2015 14:05
#include <cstdio>
int main() {
bool b = false;
*((char*)&b) = 2;
if(b == true) printf("b is true!\n");
if(b == false) printf("b is NOT true!\n");
return 0;
#include <cstdio>
#include <cstring>
int main() {
bool b = false;
char buf[10];
buf[0] = '\0';
strcat(buf, "hello kittieeeeeeeeeeee!\n");
//*((char*)&b) = 2;
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
try {
char* p = new char[10485760000];
delete [] p;
cout << "alloced!" << endl;
} catch(std::exception& e) {
#include <cstdio>
#include <cstring>
struct RAII {
~RAII() {
char buf[1000];
memset(buf, 'A', 1000);
}
};
void thrower() {
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
enum class Crap {
A = 0,
B,
C,
#include <cstdlib>
#include <iostream>
using namespace std;
struct RAII {
RAII() { cout << "ctor" << endl; }
~RAII() { cout << "dtor" << endl; }
};
RAII global; // dtor WILL be called!
#include <iostream>
template <class F, class... Args>
void for_each_argument(F f, Args&&... args) {
[](...){}((f(std::forward<Args>(args)), 0)...);
}
void print(int in) {
std::cout << in << std::endl;
}