- x outlives y
- When y is alive, x is alive. But x and y can be destroyed at the same time. That is, x must live at least as long as y.
- x strictly outlives y
- When y is alive, x is alive, and x must be alive when y is destroyed. That is, x lives longer than y.
- If starttime(z) and endtime(z) are the timestamps when z is created and destroyed, then
- x outlives y: (starttime(x) <= starttime(y)) ∧ (endtime(x) >= endtime(y)).
- x strictly outlives y: (starttime(x) <= starttime(y)) ∧ (endtime(x) > endtime(y)).
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
# Build C++ client example | |
# Process with GNU make | |
all: test | |
check: all | |
./test | |
HEADER := lru_table.h | |
CXXFLAGS = -g -Wall -std=c++17 -DLRU_TABLE_DEBUG=1 |
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 <assert.h> | |
#include <iostream> | |
#include <string> | |
#include <unordered_map> | |
class Player { | |
public: | |
static void DoAction(std::string action) { | |
std::string message; |
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
#[derive(Clone, Debug, PartialEq)] | |
enum Channel { | |
FrontLeft = 0, | |
FrontRight = 1, | |
FrontCenter = 2, | |
LowFrequency = 3, | |
BackLeft = 4, | |
BackRight = 5, | |
FrontLeftOfCenter = 6, | |
FrontRightOfCenter = 7, |
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
#ifndef FINALLY_H | |
#define FINALLY_H | |
#include <utility> | |
template<class Lambda> | |
class Finally { | |
public: | |
Finally(Lambda &&func): func_(std::forward<Lambda>(func)) {}; | |
~Finally() { func_(); }; |
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
fn main() { | |
println!("123 * 345 = {}", multiply(123, 345)); | |
} | |
fn multiply(mut a: u32, mut b: u32) -> u32 { | |
let mut sum = 0; | |
while a != 0 { | |
if a & 1 == 1 { | |
sum = add(sum, b); | |
} |
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
all: | |
# Build a static library | |
gcc -c -o query.o query.c | |
ar rcs libquery.a query.o | |
# Build and run a C sample | |
gcc sample.c libquery.a -o sample-c | |
./sample-c | |
# Build and run a C++ sample | |
g++ sample.cpp libquery.a -o sample-cpp | |
./sample-cpp |
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
all: | |
rustc property_listener_native_apis.rs | |
rustc property_listener_generic_type.rs | |
rustc property_listener_within_context.rs | |
clean: | |
rm property_listener_native_apis | |
rm property_listener_generic_type | |
rm property_listener_within_context |
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
mod sys; | |
use std::ffi::CString; | |
use std::os::raw::c_void; | |
use std::{thread, time::Duration}; | |
// A macro to print the function name | |
macro_rules! function { | |
() => {{ | |
fn f() {} |
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
all: | |
# Build a static library from the Rust file | |
rustc --crate-type=staticlib ext.rs | |
# Compile the C file with the static library | |
# gcc -o sample-c sample.c libext.a | |
gcc -o sample sample.c -L. -lext | |
./sample | |
clean: | |
rm libext.a | |
rm sample |