Skip to content

Instantly share code, notes, and snippets.

View dkorolev's full-sized avatar
💭
Live long and prosper.

Dima dkorolev

💭
Live long and prosper.
View GitHub Profile

Keybase proof

I hereby claim:

  • I am dkorolev on github.
  • I am dkorolev (https://keybase.io/dkorolev) on keybase.
  • I have a public key whose fingerprint is 0127 DF62 0BDD E3BE C7C9 7BFE A4E7 FF85 790C A9CF

To claim this, I am signing this object:

@dkorolev
dkorolev / gist:8c79ac6dbde8ce1d93e1
Created December 20, 2014 19:52
Learned today that C++11 does not support overloading by lambda type.

c++11-lambda-type.cc

#include <functional>

void foo(std::function<void()>) {}
void foo(std::function<bool()>) {}

int main() {
  foo([]() -> bool { return true; });
}
@dkorolev
dkorolev / github-install.sh
Created December 27, 2014 21:17
github-install.sh
#!/bin/bash
#
# This script downloads the master branch of some GitHub repository and installs it in current directory.
GITHUB_REPO=${1:-Bricks}
GITHUB_USER=${2:-KnowSheet}
GITHUB_BRANCH=${3:-master}
TMPDIR=tmp
@dkorolev
dkorolev / github-install.sh
Created December 27, 2014 22:51
github-install-v2.sh
#!/bin/bash
#
# This script downloads the specified GitHub repository and installs it in current directory.
set -u -e
# Command-line parameters.
GITHUB_REPO=${1:-Bricks}
GITHUB_USER=${2:-KnowSheet}
GITHUB_BRANCH=${3:-master}
@dkorolev
dkorolev / coverage-report.sh
Created December 27, 2014 23:29
coverage-report.sh
#!/bin/bash
#
# Generates code coverage report using gcov/geninfo/genhtml for each .cc file in current directory.
set -u -e
CPPFLAGS="-std=c++11 -g -Wall -W -fprofile-arcs -ftest-coverage"
LDFLAGS="-pthread"
TMPDIR=tmp
@dkorolev
dkorolev / check-headers.sh
Created December 27, 2014 23:51
check-headers.sh
#!/bin/bash
#
# Checks that every header can be compiled independently.
#
# Compiles each header with g++ and clang++, then links them all together
# to confirm the one-definition-rule is not violated, i.e., all the
# `inline`-s are set and the library really is header-only.
set -u -e
@dkorolev
dkorolev / tempate-d using.
Created April 8, 2015 15:30
tempate-d using.
#include <iostream>
enum class Selector : int { A, B };
struct ImplA {
void foo() {
std::cout << "A::foo()" << std::endl;
}
int a;
constexpr static bool is_a = true;
// V1: Types `A` and `B` hardcoded.
#include <cstdio>
#include <memory>
// Library code.
struct A;
struct B;
@dkorolev
dkorolev / visitor_v2.cc
Created April 26, 2015 05:43
visitor_v2.cc
// V2: Using the type list, to allow user-defined dispatching.
#include <cstdio>
#include <vector>
#include <utility>
// Library code.
template<typename>
struct Visitor {
@dkorolev
dkorolev / variadic_visitor.cc
Created April 26, 2015 06:34
C++11 Visitor Pattern with Variadic Template
#include <cstdio>
#include <vector>
#include <utility>
// Library code.
template<typename>
struct Visitor {
};