Skip to content

Instantly share code, notes, and snippets.

View oliora's full-sized avatar

Andrey Upadyshev oliora

View GitHub Profile
@oliora
oliora / pseudo_fork.cpp
Last active August 29, 2015 14:07
pseudo fork with C++11
void func_with_fork()
{
// local vars
auto r = std::async(std::launch::async, [&]() {
// forked thread code
});
// main thread code
@oliora
oliora / boost_msvs2013.patch
Created December 5, 2014 10:17
Boost 1.55 patches for MSVS2013
From 6252e5f867d6e1bea603aa2a0e24e6e0b861ea9f Mon Sep 17 00:00:00 2001
From: Andrey Upadyshev <andrey.upadyshev@satprofbv.com>
Date: Tue, 18 Nov 2014 18:48:52 +0100
Subject: Log patch: fixes incorrect output of the dump manipulator, when used
on AVX2-enabled CPU (e.g. Intel Haswell).
---
libs/log/src/dump_avx2.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@oliora
oliora / logger.cpp
Last active August 29, 2015 14:13
Simple Global Logger
#include "logger.h"
Logger Logger::instance_;
void Logger::log()
{
//...
}
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index 14e2794..01bb31d 100644
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -2378,7 +2378,7 @@ public:
Printv(f->def, linkage, builtin_ctor ? "int " : "PyObject *", wname, "(PyObject *self, PyObject *args) {", NIL);
Wrapper_add_local(f, "argc", "int argc");
- Printf(tmp, "PyObject *argv[%d]", maxargs + 1);
+ Printf(tmp, "PyObject *argv[%d] = {}", maxargs + 1);
@oliora
oliora / gist:4944368
Created February 13, 2013 12:45
Bug in batch-file processing: close parenthesis in echo treated as code block close
@echo off
if 1==0 (
echo first build (debug)
echo second build (release)
)
@oliora
oliora / echo.bat
Created February 13, 2013 13:19
How to echo text from batch-file without end of line
(echo %version%) > version.txt
@oliora
oliora / str_range.hpp
Created August 13, 2013 22:04
Sample of different template specialization for raw array and ptr (const char[N] and const char *).
template<typename T>
struct StrRange;
template<size_t N>
struct StrRange<const char[N]>
{
typedef const char * ConstIterator;
StrRange(const char (&t)[N])
: m_begin(t)
#include <iostream>
template<typename T>
struct Foo
{
void do_something();
Foo()
{
std::cout << "ctor" << std::endl;
@oliora
oliora / test_uref_types.cpp
Last active February 18, 2016 09:37
Print value category and constness of a universal reference for all the different argument options
#include <iostream>
#include <type_traits>
#include <utility>
namespace {
struct Func
{
Func() = default;
#include <type_traits>
#include <utility>
#include <algorithm>
namespace has_own_find_impl__ {
struct two__ { char c__[2]; };
template <class T> static two__ test__(...);
template <class T> static char test__(decltype(std::declval<T>().find(std::declval<typename T::key_type>()))* = 0);