Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
let cat = Cat { | |
meow_factor: 7 | |
purr_factor: 8 | |
}; | |
let dog = Dog { ... }; | |
let clone_mammal: &CloneMammal; | |
if get_random_bool() == true { | |
clone_mammal = &cat; |
This file contains 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
let cat = Cat { | |
meow_factor: 7 | |
purr_factor: 8 | |
}; | |
// No problem, a CloneMammal is impl for Cat | |
let clone_mammal: &CloneMammal = cat; | |
// Error! | |
let clone: &Clone = &clone_mammal; |
This file contains 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
trait CloneMammal: Clone + Mammal{} | |
impl<T> CloneMammal for T where T: Clone + Mammal{} |
This file contains 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() | |
} | |
} |
This file contains 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 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 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 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 { |
NewerOlder