This file contains hidden or 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
| num test_enum | |
| { | |
| A, | |
| B, | |
| C | |
| }; | |
| template<test_enum T> | |
| int f(int x); |
This file contains hidden or 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
| template<typename T> | |
| class Foo { | |
| public: | |
| Foo() { | |
| ++c; | |
| } | |
| private: | |
| thread_local static int c; | |
| }; |
This file contains hidden or 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
| # Compile c++ to llvm bytecode | |
| clang++ -S -emit-llvm -o bytecode.ll $1 | |
| # Convert bytecode to C | |
| llc -march=c -o code.c bytecode.ll | |
| # 'fix' static inline. This is a workaround for a bug | |
| # in one of the parsers, I think. | |
| sed -i 's/static inline.*//' code.c |
This file contains hidden or 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
| #include <cstdlib> | |
| #include <iostream> | |
| struct Mammal { | |
| Mammal() { std::cout << "Mammal::Mammal\n"; } | |
| virtual ~Mammal() { std::cout << "Mammal::~Mammal\n"; }; | |
| virtual void run() = 0; | |
| virtual void walk() = 0; | |
| virtual void move() { walk(); } | |
| }; |
This file contains hidden or 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
| int main() { | |
| Mammal *m; | |
| if (rand() % 2) { | |
| m = new Cat(); | |
| } else { | |
| m = new Dog(); | |
| } | |
| m->walk(); | |
| delete m; |
This file contains hidden or 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
| #include <iostream> | |
| #include <cstdlib> | |
| struct Mammal { | |
| Mammal() { std::cout << "Mammal::Mammal\n"; } | |
| virtual ~Mammal() {} | |
| virtual void walk() { std::cout << "Mammal::walk\n"; } | |
| }; | |
| struct Cat : Mammal { |
This file contains hidden or 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
| Bat* bat = new Bat(); | |
| Bird* b = bat; | |
| Mammal* m = bat; |
This file contains hidden or 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
| """ A simple script to locate vtable groups in binaries with the Itanium ABI. | |
| Note that this script does not account for virtual inheritance or (more notably), | |
| cases were the vtable contains null pointers. This may happen in more recent | |
| compilers with purely abstract types. | |
| """ | |
| import idaapi | |
| import idautils |
This file contains hidden or 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
| struct CloningLab { | |
| subjects: Vec<Box<Mammal>>, | |
| } | |
| trait Mammal { | |
| fn walk(&self); | |
| fn run(&self); | |
| } | |
| #[derive(Clone)] |
This file contains hidden or 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
| struct CloningLab { | |
| subjects: Vec<Box<Mammal + Clone>>, | |
| } | |
| impl CloningLab { | |
| fn clone_subjects(&self) -> Vec<Box<Mammal + Clone>> { | |
| self.subjects.clone() | |
| } | |
| } |
OlderNewer