Skip to content

Instantly share code, notes, and snippets.

View daniel-j-h's full-sized avatar
🤗

Daniel J. H. daniel-j-h

🤗
View GitHub Profile
@daniel-j-h
daniel-j-h / CompileTimeType.cc
Last active August 29, 2015 14:17
CompileTimeType: force compiler to show you inferred types
// See: EMC++, Item 4
template<typename>
class CompileTimeType;
int main() {
int x;
CompileTimeType<decltype(x)> x_Type;
@daniel-j-h
daniel-j-h / SimpleRecord.cc
Last active August 29, 2015 14:17
SimpleRecord: unscoped enum tuple accessor trick
#include <iostream>
#include <string>
#include <tuple>
// See: EMC++, Item 10
namespace {
using Person = std::tuple<std::string, std::string, int>;
enum { FirstName, LastName, Age };
}
@daniel-j-h
daniel-j-h / z3bug.cc
Created June 24, 2015 15:56
Z3 issue: toStream gives different result as toInt conversion
#include <iostream>
#include <z3++.h>
int main() {
z3::config config;
z3::context context{config};
z3::optimize optimizer{context};
auto x = context.int_const("x");
@daniel-j-h
daniel-j-h / comparator.cc
Last active August 29, 2015 14:27
Proving the Strict Weak Ordering property
bool operator()(const InternalExtractorEdge &lhs, const InternalExtractorEdge &rhs) const
{
return (lhs.result.source < rhs.result.source) ||
((lhs.result.source == rhs.result.source) &&
(lhs.result.target < rhs.result.target));
}
set disassembly-flavor intel
@daniel-j-h
daniel-j-h / parallel-modernize.sh
Last active August 29, 2015 14:27
clang-modernize all the things (in parallel)
#!/usr/bin/env bash
git ls-files '*.cpp' | \
xargs -I{} -P $(nproc) clang-modernize -p build -final-syntax-check -format -style=file -summary -for-compilers=clang-3.4,gcc-4.8 -include . -exclude third_party {}
@daniel-j-h
daniel-j-h / default.yaml
Created August 18, 2015 21:53
default cncc style --- accept everything
unexposed_decl: '^.*$'
struct_decl: '^.*$'
union_decl: '^.*$'
class_decl: '^.*$'
enum_decl: '^.*$'
field_decl: '^.*$'
enum_constant_decl: '^.*$'
function_decl: '^.*$'
var_decl: '^.*$'
parm_decl: '^.*$'
@daniel-j-h
daniel-j-h / on.cc
Last active September 7, 2015 22:35
compare greater on age
#include <iostream>
#include <ostream>
#include <algorithm>
#include <iterator>
#include <functional>
#include <type_traits>
struct Person {
int age;
@daniel-j-h
daniel-j-h / warnings.txt
Created September 9, 2015 22:34
cmake .. -DCMAKE_BUILD_TYPE=Release -Wdev --warn-uninitialized --warn-unused-vars
CMake Warning (dev) in /tmp/osrm-backend/CMakeLists.txt:
unused variable (changing definition) 'CMAKE_CURRENT_SOURCE_DIR'
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) in /tmp/osrm-backend/CMakeLists.txt:
unused variable (changing definition) 'CMAKE_CURRENT_BINARY_DIR'
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at /tmp/osrm-backend/CMakeLists.txt:9 (project):
unused variable (out of scope) 'CMAKE_BINARY_DIR'
@daniel-j-h
daniel-j-h / on.cc
Created September 11, 2015 22:16
sortBy (greater `on` age)
#include <iostream>
#include <ostream>
#include <algorithm>
#include <iterator>
#include <functional>
#include <type_traits>
struct Person {
int id;
int age;