Skip to content

Instantly share code, notes, and snippets.

@werto87
werto87 / launch.json
Last active June 28, 2022 02:52
visual code debug setup
{
"version": "0.2.0",
"configurations": [
{
"name": "test",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/_test",
"args": [],
"stopAtEntry": false,
@werto87
werto87 / cxxoptsMagnum.cxx
Created October 25, 2021 16:38
cxxopts and magnum possible memory leak small example
/*
This file is part of Magnum.
Original authors — credit is appreciated but not required:
2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021
— Vladimír Vondruš <mosra@centrum.cz>
2018 — ShaddyAQN <ShaddyAQN@gmail.com>
#include <boost/asio.hpp>
#include <iostream>
#include <memory>
#include <optional>
class session : public std::enable_shared_from_this<session>
{
public:
session (boost::asio::ip::tcp::socket &&socket) : socket (std::move (socket)) {}
// prime calculation based on https://gist.github.com/rongjiecomputer/d52f34d27a21b8c9c9e82ca85b806640
// add increase limits or it wont compile for sieveSize = 1000000 -fconstexpr-loop-limit=2000000 -fconstexpr-ops-limit=335544320
// use debug build.
// release build will optimize most of the loop away.
#include <chrono>
#include <iostream>
#include <numeric>
#include <span>
#include <stdio.h>