Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Hodges madmongo1

View GitHub Profile
View find_path.cpp
#include <boost/json.hpp>
#include <iostream>
#include <sstream>
namespace json = boost::json;
struct unwrap
{
unwrap(std::exception &e)
@madmongo1
madmongo1 / scratch.cpp
Created Oct 7, 2021
Cancellable async_resolve
View scratch.cpp
//
// Copyright (c) 2021 Richard Hodges (hodges.r@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include <asio.hpp>
#include <iostream>
#include <asio/experimental/append.hpp>
View invariants.cpp
struct invariants;
struct invariants_builder
{
void set(std::string const& index, std::any item);
invariants commit();
};
/// A map of type -> any.
@madmongo1
madmongo1 / atomic_transfer.cpp
Created Jun 1, 2021
Atomic transfer between polymorphic producer and consumer
View atomic_transfer.cpp
/// @brief The result of attemping an atomic produce, consume or produce and
/// consume.
struct io_transfer_result
{
/// 1 if the transfer completed
unsigned char success : 1 = 0;
/// 1 if the consumer is in the completed state
unsigned char consumed : 1 = 0;
@madmongo1
madmongo1 / decorator-check.cpp
Created May 27, 2021
Checks the beast websocket decorator
View decorator-check.cpp
#include <boost/asio.hpp>
#include <boost/beast/core/flat_buffer.hpp>
#include <boost/beast/http.hpp>
#include <boost/beast/websocket.hpp>
#include <iostream>
#include <map>
#include <string>
using namespace boost::beast;
namespace asio = boost::asio;
View gist:0b7cec000bbb4f563605f4f3d434d9c2
if(NOT REQUIRE_BOOST_CMAKE)
set(REQUIRE_BOOST_CMAKE 1)
else()
return()
endif()
#
# file level configuation
#
@madmongo1
madmongo1 / condvar.hpp
Created Jan 30, 2021
An inline coroutine completion handler which completes waiting coroutines inline
View condvar.hpp
/// An inline coroutine completion handler which completes waiting coroutines
/// inline (without post or dispatch).
struct condvar_impl
{
struct waiter_concept
{
virtual bool
pred() const = 0;
virtual void
View workaround.cpp
template<class F>
concept mutable_value_visitor =
requires(F f, value& v)
{
{ f(v) };
};
template < mutable_value_visitor Visitor >
void
enumerate(value &v, Visitor f)
View gist:a47e4f78d7b60952a5b0dad47e4a563a
diff --git a/include/boost/beast/_experimental/test/impl/stream.hpp b/include/boost/beast/_experimental/test/impl/stream.hpp
index f7eac6afd..9f8dc63cd 100644
--- a/include/boost/beast/_experimental/test/impl/stream.hpp
+++ b/include/boost/beast/_experimental/test/impl/stream.hpp
@@ -27,7 +27,8 @@ namespace test {
//------------------------------------------------------------------------------
-struct stream::service_impl
+template<class Executor>
View variant_websocket.cpp
std::string
deduce_port(std::string const &scheme, std::string port)
{
using boost::algorithm::iequals;
if (port.empty())
{
if (iequals(scheme, "ws") or iequals(scheme, "http"))
port = "http";
else if (iequals(scheme, "wss") or iequals(scheme, "https"))