Header-only C++ boilerplate code shipped with Boost, fmt, prettyprint. Requires at least C++11.
size_t get_filesize(const boost::filesystem::path& path);std::string read_file(const boost::filesystem::path& path);std::chrono::milliseconds::rep ms_since_epoch();std::string get_current_datetime_str();to_t evil_cast(from_t&& f);std::unique_ptr<T> make_unique(Args&&... args);struct identity;std::chrono::milliseconds measure_execution_time(func_t&& func, Args&&... args);benchmark_escape(void *p)andbenchmark_clobber()funcs to prevent optimizer ruin your performance analysistype_name<T>()to get string representation of object type- user-defined chrono literals
- generic
std::hashfor enum types - all commonly used std includes
sandbox::binIO manipulator- simple logger:
LOG() << fmt::format("some value: {}", some_value);LOG(std::cerr) << "something" << " else";
osyncto make std streams thread safe:std::cout << sandbox::osync << "thread " << "safe";
- simple thread pool
flat_mapandflat_setcontainers: these arestd::mapandstd::setimplementations using a contiguous data structure as the underlying storage.
git clonethis repo next to yourmain.cpp- Place
include(cpp_sandbox/CMakeLists.txt)at the end of yourCMakeLists.txt #define SANDBOX_DONT_USE_NAMESPACEif you don't want anyusing namespace#include "cpp_sandbox/sandbox.hpp"and have fun!