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
#pragma once | |
#include <future> | |
/** | |
* Class template based on std::async and std::future<> to help in fetching data asynchronously. | |
*/ | |
template <typename T> | |
struct async_data { |
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
const std = @import("std"); | |
const c = @cImport({ | |
// @cInclude("imgui/imgui.h"); | |
// @cInclude("imgui/imgui_internal.h"); | |
@cInclude("imgui/imstb_truetype.h"); | |
@cInclude("imgui/imstb_rectpack.h"); | |
}); | |
const assert = std.debug.assert; |
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> | |
/*======================================================================= | |
* ASPECT COMPOSITION | |
*======================================================================*/ | |
/* This is the base class to be specialized via CRTP. | |
* | |
* It must provide all the methods that aspects can override as no-ops. | |
*/ |
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> | |
/*======================================================================= | |
* ASPECT COMPOSITION | |
*======================================================================*/ | |
template<class Parent> | |
struct Nil_aspect: public Parent | |
{ | |
void tell() {} // no-op, and ends the chain |
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> | |
class A { | |
public: | |
void method1(); | |
void method2(int); | |
static void method3(int []); | |
}; |
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
/* | |
* 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; |
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
# 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 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 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 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; | |
} |
NewerOlder