This file contains 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 <iostream> | |
#include <cds/container/cuckoo_map.h> | |
#include <string> | |
#include <utility> | |
struct hash1 { | |
size_t operator()(std::string const& s) const | |
{ |
This file contains 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 <future> | |
#include <iostream> | |
#include <type_traits> | |
using namespace std; | |
// Adapted from http://stackoverflow.com/questions/14200678/c11-async-continuations-or-attempt-at-then-semantics | |
This file contains 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 <atomic> | |
#include <memory> | |
#include <iterator> | |
#include <utility> | |
#include <assert.h> | |
// | |
// Lock free singly-linked using shared_ptr (if atomic_* for shared_ptr is lock_free) | |
// You can get the head, and push_front | |
// You can replace the head |
This file contains 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 <iostream> | |
/* This will let macros expand before concating them */ | |
#define CROSS_COMPILER_INTERFACE_PRIMITIVE_CAT(x, y) x ## y | |
#define CROSS_COMPILER_INTERFACE_CAT(x, y) CROSS_COMPILER_INTERFACE_PRIMITIVE_CAT(x, y) | |
// Adapted from http://stackoverflow.com/questions/11920577/casting-all-parameters-passed-in-macro-using-va-args | |
// With adaptations for MSVC from BOOST_PP | |
/* This counts the number of args */ |
This file contains 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
// Adapted from http://stackoverflow.com/questions/12707030/sequence-range-unroll-using-variadic-templates | |
template<unsigned...> struct indices{}; | |
template<unsigned N, unsigned... Indices> | |
struct indices_gen : indices_gen<N-1, N-1, Indices...>{}; | |
template<unsigned... Indices> | |
struct indices_gen<1, Indices...>{ | |
typedef indices<0, Indices...> type; | |
}; |
This file contains 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 <iostream> | |
#include <string> | |
// Reusable | |
template<int i, class T> | |
struct optional_type{ | |
enum{ pos = i}; | |
typedef T value_type; |
This file contains 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
// Copyright John R. Bandela 2012. | |
// Distributed under the Boost Software License, Version 1.0. | |
// (See accompanying file LICENSE_1_0.txt or copy at | |
// http://www.boost.org/LICENSE_1_0.txt) | |
#include <cstddef> | |
#include <string> | |
// On Windows use stdcall | |
#define CROSS_CALL_CALLING_CONVENTION __stdcall |
This file contains 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 <functional> | |
#include <iostream> | |
#include <assert.h> | |
#include <cstddef> | |
typedef void(*ptr_fun_void_t)(); | |
struct vtable{ |
This file contains 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 <iostream> | |
using namespace std; | |
template<class Class, class Type, const Type& (Class::*Getter)(),void (Class::*Setter)(const Type&)> | |
class property{ | |
Class* p_; | |
Class* calc_p(const property& other){ | |
auto diff = reinterpret_cast<const char*>(&other) - reinterpret_cast<const char*>(other.p_); | |
return reinterpret_cast<Class*>(reinterpret_cast< char*>(this) - diff); |
This file contains 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 JRB_COCOS_H | |
#include <stdexcept> | |
struct InitFailed:public std::exception{ | |
InitFailed():std::exception("init Failed"){} | |
}; | |
template<class T, class... Parms> | |
cocos2d::CCScene* createScene(Parms&&... p){ |