Skip to content

Instantly share code, notes, and snippets.

@martong
martong / gist:4ec88a9c58b587dbcdf9
Created March 14, 2015 12:20
manually discriminated union
#include <gtest/gtest.h>
#include <typeinfo>
#include <unordered_map>
#include <string>
struct X0 {};
struct X1 {};
using TypeInfoRef = std::reference_wrapper<const std::type_info>;
@martong
martong / README.md
Last active August 29, 2015 14:17
A variadic typelist which models boost::mpl Sequence concept

Description Current boost::variant (1.57) is capable of handling any kind of type sequences until it fulfills (models) mpl's Sequence concept [1][2]. However boost::mpl::vector can't handle more than 50 types at the moment. Even with a C++11 compiler that limits is strict. So I took Dave Abrahams' C++11 variadic typelist [3] and added some glue code to that, so it models the mpl's Sequence concept.

I've tested it with boost 1.56 and with the clang compiler which comes with OSX Yosemite (Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn))

Also I've made some measurements on a private project:

@martong
martong / ycm_extra_conf.py
Last active August 29, 2015 14:03
ycm_extra_conf.py to find flags in compilation database for headers whose counterpart source file is not existent. This is done by trying to find the first source in the project directory, which includes the header. If still not found a candidate src file, then try to browse the json db to find one, which uses the directory of our header as an i…
import os
import fnmatch
import re
import ycm_core
import json
import itertools
# Set this to the absolute path to the folder (NOT the file!) containing the
# compile_commands.json file to use that instead of 'flags'. See here for
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html