Skip to content

Instantly share code, notes, and snippets.

View djarek's full-sized avatar

Damian Jarek djarek

  • Poland/Wrocław
View GitHub Profile
@djarek
djarek / send_fd.cpp
Created December 6, 2018 01:59
send_fd.cpp
#include <boost/asio/coroutine.hpp>
#include <boost/asio/local/connect_pair.hpp>
#include <boost/asio/local/stream_protocol.hpp>
#include <iostream>
#include <sys/wait.h>
std::size_t
send_fd(boost::asio::local::stream_protocol::socket& socket,
int fd,
boost::system::error_code& ec)
@djarek
djarek / post_hang.cpp
Last active December 4, 2018 23:55
post_hang.cpp
struct test_op
{
using executor_type = boost::asio::io_context::executor_type;
executor_type get_executor() const noexcept
{
return ctx1.get_executor();
}
void operator()()
#include <lua.h>
#include <type_traits>
template<typename LuaPushable>
void LuaPush(lua_State& state, LuaPushable&& luaPushable);
template <>
void LuaPush(lua_State& state, const std::string& str)
{
lua_pushlstring(&state, str.c_str(), str.length());
template <typename T, typename U=void, typename... Types>
constexpr size_t index() {
return std::is_same<T, U>::value ? 0 : 1 + index<T, Types...>();
}
template<size_t index, typename... T>
struct TypeAtIndex
{
using type = typename std::tuple_element<index, std::tuple<T...>>::type;
};