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 <boost/iterator/iterator_facade.hpp> | |
#include <boost/range/iterator_range.hpp> | |
#include <iterator> | |
#include <utility> | |
template<class Iter1, class Iter2,class Comp> | |
struct set_intersection_iterator:public boost::iterator_facade<set_intersection_iterator<Iter1,Iter2,Comp>,const typename std::iterator_traits<Iter1>::value_type,std::forward_iterator_tag> | |
{ | |
Iter1 begin1_; | |
Iter1 end1_; |
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 <tuple> | |
#include <utility> | |
#include <cstdint> | |
#include <stdexcept> | |
using std::size_t; | |
template<typename F, typename Tuple, size_t... I> | |
auto | |
apply_(F&& f, Tuple&& args, std::integer_sequence<size_t,I...>) |
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
// For motivation see stackoverflow | |
// http://stackoverflow.com/questions/13612832/template-for-referencing-classes-themselves-rather-than-a-class-that-uses-templa | |
#include <iostream> | |
#include <string> | |
#include <typeinfo> | |
#include <cstring> | |
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){ |
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
#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 <numeric> | |
template<class T> | |
constexpr T cfact(unsigned f) { | |
return f?cfact<T>(f - 1)*f : 1; | |
} | |
template<class T> | |
constexpr T factorial_max_helper(T value_so_far, unsigned f) { |
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 <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
// 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; | |
}; |
OlderNewer