Skip to content

Instantly share code, notes, and snippets.

View tomilov's full-sized avatar

Anatoliy V Tomilov tomilov

  • Yandex
  • Yekaterinburg
View GitHub Profile
#!/usr/bin/env bash -vex
find ~ -maxdepth 2 -mindepth 2 -name ".git" -type d -print -execdir git pull \;
@tomilov
tomilov / allocator.cpp
Last active October 7, 2015 06:34
Howard Hinnant's short_allocator implementation
#include <iostream>
#include <ostream>
#include <utility>
#include <type_traits>
#include <functional>
#include <memory>
#include <vector>
#include <cstdlib>
#include <cassert>
@tomilov
tomilov / lambda_enable_if.cpp
Created October 6, 2015 05:51
using enable_if as return type of lambda function
#include <type_traits>
#include <utility>
#include <iostream>
#include <cassert>
#include <cstdlib>
namespace details
{
@tomilov
tomilov / global_functor_on_demand.cpp
Created October 6, 2015 05:53
call qualified operator () of stateless global functor constructed on demand
#include <iostream>
#include <type_traits>
#include <utility>
#include <cstdlib>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wglobal-constructors"
template< typename F >
F callee = {};
@tomilov
tomilov / phash.cpp
Created October 6, 2015 06:02
crc32 hash
#include <iostream>
#include <cstdlib>
#include <cstddef>
#include <cstdint>
#include <x86intrin.h>
struct phash
{
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cstdlib>
int
main()
{
@tomilov
tomilov / get and build latest boost on ubuntu.lua
Last active November 24, 2015 05:33
Lua script to clone latest revision of boost repository and to clone latest revisions of all the submodules. Also containing hints of how to build and install boost complitely. The download traffic is minimal possible: only single branch, only latest revision of the branch.
-- mkdir boost ; cd boost ; lua ../git-submodules-clone-HEAD.lua https://github.com/boostorg/boost.git .
local module_url = arg[1] or 'https://github.com/boostorg/boost.git'
local module = arg[2] or module_url:match('.+/([_%d%a]+)%.git')
local branch = arg[3] or 'master'
function execute(command)
print('# ' .. command)
return os.execute(command)
end
-- execute('rm -rf ' .. module)
if not execute('git clone --single-branch --branch ' .. branch .. ' --depth=1 ' .. module_url .. ' ' .. module) then
cd
svn co https://llvm.org/svn/llvm-project/llvm/trunk llvm
cd llvm/projects/
svn co https://llvm.org/svn/llvm-project/libcxxabi/trunk libcxxabi
svn co https://llvm.org/svn/llvm-project/libcxx/trunk libcxx
svn co https://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
svn co http://llvm.org/svn/llvm-project/openmp/trunk openmp
cd ../tools
svn co https://llvm.org/svn/llvm-project/cfe/trunk clang
svn co https://llvm.org/svn/llvm-project/clang-tools-extra/trunk extra
struct S { ~S() noexcept(false) { ; } };
static_assert(noexcept(::new (nullptr) S()));
static_assert(!noexcept(S()));
struct T { T() noexcept(false) { ; } };
static_assert(!noexcept(::new (nullptr) T()));
static_assert(!noexcept(T()));
#include <type_traits>
#include <iostream>
#include <cstdlib>
#define PP { std::cout << __PRETTY_FUNCTION__ << std::endl; }
struct descriptor
{
std::size_t const s;