Skip to content

Instantly share code, notes, and snippets.

View geneotech's full-sized avatar

Patryk Czachurski geneotech

View GitHub Profile
Line 134: <ClCompile Include="3rdparty\Box2D\Collision\b2BroadPhase.cpp" />
Line 135: <ClCompile Include="3rdparty\Box2D\Collision\b2CollideCircle.cpp" />
Line 136: <ClCompile Include="3rdparty\Box2D\Collision\b2CollideEdge.cpp" />
Line 137: <ClCompile Include="3rdparty\Box2D\Collision\b2CollidePolygon.cpp" />
Line 138: <ClCompile Include="3rdparty\Box2D\Collision\b2Collision.cpp" />
Line 139: <ClCompile Include="3rdparty\Box2D\Collision\b2Distance.cpp" />
Line 140: <ClCompile Include="3rdparty\Box2D\Collision\b2DynamicTree.cpp" />
Line 141: <ClCompile Include="3rdparty\Box2D\Collision\b2TimeOfImpact.cpp" />
Line 142: <ClCompile Include="3rdparty\Box2D\Collision\Shapes\b2ChainShape.cpp" />
Line 143: <ClCompile Include="3rdparty\Box2D\Collision\Shapes\b2CircleShape.cpp" />
3rdparty\Box2D\Collision\b2BroadPhase.cpp
3rdparty\Box2D\Collision\b2CollideCircle.cpp
3rdparty\Box2D\Collision\b2CollideEdge.cpp
3rdparty\Box2D\Collision\b2CollidePolygon.cpp
3rdparty\Box2D\Collision\b2Collision.cpp
3rdparty\Box2D\Collision\b2Distance.cpp
3rdparty\Box2D\Collision\b2DynamicTree.cpp
3rdparty\Box2D\Collision\b2TimeOfImpact.cpp
3rdparty\Box2D\Collision\Shapes\b2ChainShape.cpp
@geneotech
geneotech / .cpp
Created August 1, 2016 12:46
czas.cpp
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
time_t now = time(0);
tm ltm;
localtime_s(&ltm, &now);
#include <unordered_map>
namespace std {
template <class T>
struct member_hash {
std::size_t operator()(const T& t) const {
return t.hash();
}
};
@geneotech
geneotech / constexpr_if.cpp
Created May 24, 2017 19:02
Constexpr if for compilers without support of... constexpr if.
#include <type_traits>
#include <iostream>
using namespace std;
template <bool>
struct constexpr_if;
template <>
struct constexpr_if<true> {
struct elser {
struct A { int v; };
struct B { int v; };
struct C { int v; };
struct Ar { int& v; };
struct Br { int& v; };
struct Cr { int& v; };
void add_ref(A& a, B& b, C& c) {
a.v += c.v;
b.v += c.v;
@geneotech
geneotech / menu.cpp
Last active September 15, 2017 20:06
future considerations
// UPDATE: So, I've implemented a packaged_future template which makes it possible to use just a single variable:
// https://gist.github.com/geneotech/c9e8177b34dbace6b1fa23129977c9d1
// Original problem:
// UPDATE: Okay, so apparently, std::shared_future can get multiple times...
// But should I use std::shared_future even though just one thread queries it for value?
// Consider a main menu class which, on construction,
// is supposed to query a website for a news headline in order
@geneotech
geneotech / thread_templates.h
Last active September 15, 2017 20:42
Thread templates
#pragma once
#include <future>
#include <optional>
template <class T>
bool is_ready(const std::future<T>& f) {
return f.wait_for(std::chrono::seconds(0)) == std::future_status::ready;
}
template <class T>
#include <type_traits>
#include <iostream>
template <class A, class = void>
struct has_member : std::false_type {};
template <class A>
struct has_member<A, decltype(A::member, void())> : std::true_type {};
struct AA { static constexpr bool member = true; };
mkdir .deps ; cd .deps
cmake -DCMAKE_BUILD_TYPE=Release ../third-party -G Ninja
ninja
export CFLAGS='-O3 -flto -fuse-ld=lld'
export CXXFLAGS='-O3 -flto -fwhole-program-vtables -fuse-ld=lld'
export LDFLAGS='-flto -fwhole-program-vtables -fuse-ld=lld'
../
mkdir build ; cd build
cmake -DCMAKE_BUILD_TYPE=Release .. -G Ninja
ninja