Skip to content

Instantly share code, notes, and snippets.

@beached
beached / bare_asio_server.cpp
Last active June 16, 2024 14:31
A barebones async server with Boost ASIO
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <cstdint>
#include <iostream>
#include <list>
#include <memory>
struct Connection {
boost::asio::ip::tcp::socket socket;
boost::asio::streambuf read_buffer;
@beached
beached / move_capture.cpp
Last active August 29, 2015 14:12
A wrapper to allow moving of values into a C++ 11 lambda
template<typename T>
class MoveCapture {
mutable T m_value;
public:
MoveCapture( ) = delete;
MoveCapture( T && val ) : m_value( std::move( val ) ) { }
MoveCapture( MoveCapture const & other ) : m_value( std::move( other.m_value ) ) { }
MoveCapture& operator=(MoveCapture const & rhs) {