Skip to content

Instantly share code, notes, and snippets.

@t2ym
t2ym / compile_time_truncation.h
Created June 15, 2021 02:56
Kotlin-style trimIndent() at compile time for C++ raw literals
/*
* Blog of the original author: https://davidgorski.ca/posts/truncate-string-whitespace-compiletime-cpp/
* Original source gist: https://gist.github.com/dgski/810ede7c4a80917c0adc99c6852fee9a
*
* Modifications by @t2ym (https://github.com/t2ym)
* - Rearranged as a header file
* - Surrounded main() by #ifdef COMPILE_TIME_TRUNCATION_EXAMPLE ... #endif
* - Added an argument "" to static_assert() to comply with C++11
* - Put truncateWhitespace() in the compiletime namespace
* - Made is_whitespace() inline
@t2ym
t2ym / nicexprs.h
Last active April 30, 2022 04:28
nicexprs.h: a single header file ExpressJs-like middleware API on nghttp2 asio library
/*
* Copyright (c) 2021, Tetsuya Mori <t2y3141592@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,