Boost.Demo is a header-only library for high-throughput message parsing with a modern, allocation-free API.
#include <boost/beast/core.hpp>
#include <boost/beast/http.hpp>
#include <iostream>
namespace beast = boost::beast;
namespace http = beast::http;
int main()
{
// Build an HTTP GET request
http::request<http::string_body> req{http::verb::get, "/index.html", 11};
req.set(http::field::host, "www.example.com");
req.set(http::field::user_agent, "Boost.Beast");
std::cout << req << std::endl;
// Build an HTTP response
http::response<http::string_body> res{http::status::ok, 11};
res.set(http::field::server, "Boost.Beast");
res.set(http::field::content_type, "text/plain");
res.body() = "Hello from Boost.Beast!";
res.prepare_payload();
std::cout << res << std::endl;
return 0;
}
Throughput (req/s)
Boost.Demo
Alternative A
Alternative B
Latency (microseconds)
Boost.Demo
Alternative A
Alternative B
Handles millions of messages per second with near-zero allocations on the hot path.
Add Boost to your include path — no separate build step required.
APIs mirror the C++ standard where applicable, easing future migration.
Boost.Demo is maintained by the demo team. Highlights:
Zero-allocation fast path
Extensive fuzz testing
Works on all major compilers
See the Boost website for more.
Header-only — add Boost to your include path, or build with b2.
# build it with b2:
./b2 --with-demo install
# then link against it:
g++ app.cpp -lboost_demo