Skip to content

Instantly share code, notes, and snippets.

#include <vector>
#include <sstream>
#include <msgpack.hpp>
namespace foo {
struct no_def_con {
no_def_con() = delete;
MSGPACK_DEFINE(i1, i2, v);
@redboltz
redboltz / CMakeLists.txt
Created July 4, 2017 12:16
ctest with arguments
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.12)
ENABLE_TESTING ()
STRING(REPLACE " " ";" CTEST_ARGS_LIST $ENV{CTEST_ARGS})
ADD_TEST(foo foo.sh ${CTEST_ARGS_LIST})
@redboltz
redboltz / asio_stream_buf_and_zlib_direct.cpp
Last active June 26, 2017 05:14
Use zlib directly instead of boost::iostreams::filtering_istream on uncompress.
#include <sstream>
#include <string>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/zlib.hpp>
@redboltz
redboltz / asio_iostreams_zlib_test.cpp
Created June 23, 2017 03:37
Decompressing chunked data using boost asio and boost iostreams.
#include <sstream>
#include <string>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/zlib.hpp>
MyClass mc = a == b ? c
: d == e ? f
: g;
@redboltz
redboltz / endiancheck.c
Created June 18, 2015 08:12
Boost.Predef on C
#include <boost/predef.h>
#include <stdio.h>
int main() {
printf("%d\n", BOOST_ENDIAN_BIG_BYTE);
printf("%d\n", BOOST_ENDIAN_BIG_WORD);
printf("%d\n", BOOST_ENDIAN_LITTLE_BYTE);
printf("%d\n", BOOST_ENDIAN_LITTLE_WORD);
}
@redboltz
redboltz / cleint.cpp
Created June 12, 2015 01:58
Websocket++ event handling example
// g++ -std=c++11 -Wall -Wextra client.cpp -lboost_system -pthread
#define _WEBSOCKETPP_CPP11_STL_
#define _WEBSOCKETPP_RVALUE_REFERENCES_
#define _WEBSOCKETPP_DELETED_FUNCTIONS_
#include <iostream>
#include <websocketpp/config/asio_no_tls.hpp>
#include <websocketpp/client.hpp>
@redboltz
redboltz / page41.cpp
Created June 1, 2015 02:25
SpiritX3 example on C++Now2015 Pace41(in PDF)
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/home/x3.hpp>
namespace x3 = boost::spirit::x3;
int main() {
using x3::char_;
std::string input( "cosmic pizza" );
auto iter = input.begin();
@redboltz
redboltz / base_class.cpp
Created April 9, 2015 11:05
msgpack base class support
#include <msgpack.hpp>
#include <sstream>
#include <cassert>
#include <iostream>
struct A {
int a;
MSGPACK_DEFINE(a);
};
@redboltz
redboltz / client.cpp
Created March 16, 2015 15:59
asio and Boost.Coroutine
#include <iostream>
#include <functional>
#include <boost/array.hpp>
#include <boost/asio.hpp>
#include <boost/coroutine/all.hpp>
using boost::asio::ip::tcp;
char g_data[] = {0};