Skip to content

Instantly share code, notes, and snippets.

View madmongo1's full-sized avatar

Richard Hodges madmongo1

View GitHub Profile
#include <boost/json.hpp>
#include <iostream>
#include <sstream>
namespace json = boost::json;
struct unwrap
{
unwrap(std::exception &e)
@madmongo1
madmongo1 / scratch.cpp
Created October 7, 2021 13:49
Cancellable async_resolve
//
// 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>
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 June 1, 2021 10:04
Atomic transfer between polymorphic producer and consumer
/// @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 18:46
Checks the beast websocket decorator
#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;
if(NOT REQUIRE_BOOST_CMAKE)
set(REQUIRE_BOOST_CMAKE 1)
else()
return()
endif()
#
# file level configuation
#
@madmongo1
madmongo1 / condvar.hpp
Created January 30, 2021 07:57
An inline coroutine completion handler which completes waiting coroutines inline
/// 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
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)
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>
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"))