This file contains hidden or 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
using namespace std; | |
ifstream fs(filename); | |
string s; | |
fs.seekg(0, ios::end); | |
s.reserve( (size_t) fs.tellg() ); | |
fs.seekg(0, ios::beg); | |
s.assign( istreambuf_iterator<char>(fs), istreambuf_iterator<char>() ); |
This file contains hidden or 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
var gulp = require('gulp'); | |
var gutil = require('gulp-util'); | |
var through = require('through2'); | |
/* Wrap the content of text files into CommonJS modules exporting that content as JS strings. | |
*/ | |
function textFileToCommonJS(filename, options) { | |
var lines = []; | |
This file contains hidden or 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
cmake_minimum_required(VERSION 3.0) | |
#------------------------------------------------ | |
# Project + basics | |
# | |
project(GPCFontRasterizer) | |
set(${PROJECT_NAME}_MAJOR_VERSION 0) | |
set(${PROJECT_NAME}_MINOR_VERSION 1) |
This file contains hidden or 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 <codecvt> | |
using namespace std; | |
#if _MSC_VER >= 1900 | |
wstring_convert<codecvt_utf8<int32_t>, int32_t> utf32conv; | |
auto utf32 = utf32conv.from_bytes("The quick brown fox jumped over the lazy dog."); | |
// use reinterpret_cast<const char32_t *>(utf32.c_str()) | |
#else | |
wstring_convert<codecvt_utf8<char32_t>, char32_t> utf32conv; |
This file contains hidden or 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 <type_traits> | |
#include <iostream> | |
using std::enable_if; | |
using std::is_same; | |
using std::declval; | |
using std::integral_constant; | |
template <typename T> | |
using Invoke = typename T::type; |
This file contains hidden or 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
ifstream ifs; | |
ofstream ofs; | |
istream *is = nullptr; | |
ostream *os = nullptr; | |
if (!input_file.empty()) { | |
ios_base::sync_with_stdio(false); | |
ifs.open(input_file, ios::binary); | |
is = &ifs; | |
} |
This file contains hidden or 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> | |
template <typename IndexedStruct, int Index> | |
struct _getter { | |
using Rest = decltype(std::declval<IndexedStruct>().rest); | |
static auto& get(IndexedStruct &inst) | |
{ | |
return _getter<decltype(inst.rest), Index-1>::get(inst.rest); |
This file contains hidden or 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
/* Example class for rendering a rectangle using OpenGL 4, using a vertex buffer and a | |
* vertex array object and the triangle strip primitive. | |
* | |
* Note: GL calls are wrapped into a variadic macro of the form GL(func, arg1, arg2,...). | |
*/ | |
class opengl_rectangle { | |
public: | |
void get_resources() |
This file contains hidden or 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
# Detect architecture | |
if (CMAKE_SIZEOF_VOID_P MATCHES 8) | |
set( PROJECT_ARCH "x86_64" ) | |
else(CMAKE_SIZEOF_VOID_P MATCHES 8) | |
set( PROJECT_ARCH "x86" ) | |
endif(CMAKE_SIZEOF_VOID_P MATCHES 8) | |
# FFmpeg |
This file contains hidden or 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
/* | |
* Find next NAL unit from the specified H.264 bitstream data. | |
*/ | |
static auto find_next_nal_unit(const uint8_t *start, const uint8_t *end) -> const uint8_t * | |
{ | |
const uint8_t *p = start; | |
/* Simply lookup "0x000001" pattern */ | |
while (p <= end - 3 && (p[0] || p[1] || p[2] != 1)) | |
++p; |