Skip to content

Instantly share code, notes, and snippets.

«Все это вы ни в каком учебнике не найдете,
потому что таких людей, как я, на земле нет!»
(С) А.Я. Переверзев
Все теперешнее правительство - ельциноиды. Ну, это значит, предатели.
Самый страшный враг России - это бабки, потому что они проголосовали за Ельцина.
Царя в думе встречали неприветливо. Он учел это и распустил думу.
@ShaderManager
ShaderManager / fcontext.cmake
Created January 31, 2019 12:03
fcontext cmake
enable_language(ASM)
if (WIN32)
if (MSVC)
enable_language(ASM_MASM)
if (MSVC_C_ARCHITECTURE_ID STREQUAL "x64")
set(ASM_SOURCES asm/jump_x86_64_ms_pe_masm.asm asm/make_x86_64_ms_pe_masm.asm asm/ontop_x86_64_ms_pe_masm.asm)
elseif (MSVC_C_ARCHITECTURE_ID STREQUAL "X86")
set(ASM_SOURCES asm/jump_i386_ms_pe_masm.asm asm/make_i386_ms_pe_masm.asm asm/ontop_i386_ms_pe_masm.asm)
#include <stdio.h>
#include <string>
template<typename Arg> const char* type_to_str();
template<typename...> struct VarIterator;
template<typename Head> struct VarIterator<Head>
{
static std::string eval()
error C2664: 'void openvdb::v3_1_0::tools::transformValues<openvdb::v3_1_0::tree::TreeValueIteratorBase<const openvdb::v3_1_0::tree::Tree<openvdb::v3_1_0::tree::RootNode<openvdb::v3_1_0::tree::InternalNode<openvdb::v3_1_0::tree::InternalNode<openvdb::v3_1_0::tree::LeafNode<T,3>,4>,5>>>,openvdb::v3_1_0::tree::RootNode<openvdb::v3_1_0::tree::InternalNode<openvdb::v3_1_0::tree::InternalNode<openvdb::v3_1_0::tree::LeafNode<T,3>,4>,5>>::ValueIter<const openvdb::v3_1_0::tree::RootNode<openvdb::v3_1_0::tree::InternalNode<openvdb::v3_1_0::tree::InternalNode<openvdb::v3_1_0::tree::LeafNode<T,3>,4>,5>>,std::_Tree_const_iterator<std::_Tree_val<std::_Tree_simple_types<std::pair<const _Kty,_Ty>>>>,openvdb::v3_1_0::tree::RootNode<openvdb::v3_1_0::tree::InternalNode<openvdb::v3_1_0::tree::InternalNode<openvdb::v3_1_0::tree::LeafNode<T,3>,4>,5>>::ValueOnPred,const float>>,openvdb::v3_1_0::Grid<openvdb::v3_1_0::Vec3STree>,void(__cdecl *)(const openvdb::v3_1_0::tree::TreeValueIteratorBase<const openvdb::v3_1_0::tree::Tree<open
@ShaderManager
ShaderManager / is_unique.cpp
Created November 9, 2015 17:49
Check if types are unique among sequence of types of variadic templates
namespace detail
{
template<typename Selector, typename A, typename B> using choose = typename std::conditional<Selector::value, A, B>::type;
struct empty {};
template<typename T> struct id {};
template<typename A, typename B> struct base : A, B {};
// Check if id<Head> is base class for type B. If it's true, then we have already instantiated Head type somewhere before this step
%module pugixml
%{
#define SWIG_FILE_WITH_INIT
#include "pugixml.hpp"
%}
%include "pugixml.hpp"
/*
Sort 4 floats in SSE vector using sorting network and return indices of moved values
*/
inline __m128i v4_sort(__m128& v)
{
auto i = _mm_castsi128_ps(_mm_set_epi32(3, 2, 1, 0));
const auto mask = _mm_castsi128_ps(_mm_set1_epi32(0xFFFFFFFC));
// Place indices in lower 2 bits of mantissa
v = _mm_or_ps(_mm_and_ps(v, mask), i);
bool check(const std::string& s, const std::vector<std::string>& d)
{
auto ts = s;
while (true)
{
auto match = std::make_pair(ts.npos, 0);
for (auto&& w : d)
{