This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// string format | |
// by cos 2020. licensed under MIT | |
#pragma once | |
#include <string> | |
#include <sstream> | |
namespace detail { | |
template<class CharT> | |
void format_impl(std::basic_ostringstream<CharT> &oss, const CharT *s) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <string> | |
// observer-based logic gate simulation | |
// things are done in a naive way. one may have stack overflow | |
// if events invoke each other | |
// interfaces |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <vector> | |
// inspiration: boost/assign/std/vector.hpp | |
template<class VT> struct vector_inserter { | |
VT &vec; | |
template<class Arg> auto &operator,(Arg &&v) { | |
vec.emplace_back(std::forward<Arg>(v)); | |
return *this; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Lambda traits (c) cos Licensed under BSD 2-Clause */ | |
#pragma once | |
#include <tuple> | |
namespace detail { | |
template<typename R, typename ...Args> | |
struct lambda_traits_base_noconst { | |
using result_type = R; | |
using args_type = std::tuple<Args...>; | |
template<size_t idx> using arg_type_at = std::tuple_element_t<idx, args_type>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <functional> | |
#include <iostream> | |
#include <memory> | |
#include <queue> | |
#include <vector> | |
template<typename V> | |
class Tree; | |
template<typename V> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -std=c++17 (auto parameter, inline variable) | |
// x64msvc>=v19.20, x64clang>=5.0.0, x64gcc>=8.1 | |
#include <utility> // integer_sequence | |
namespace num { | |
template <typename T, T n> | |
struct _pack { | |
using type = _pack; | |
using value_type = T; | |
static constexpr T value = n; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -std=c++11 | |
// licensed under MIT | |
// 2020 cos https://opensource.org/licenses/MIT | |
#include <iostream> | |
namespace li { | |
template <int n> struct int32 { | |
using type = int32; | |
static constexpr int value = n; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** https://www.typescriptlang.org/docs/handbook/advanced-types.html */ | |
/** intersection type */ | |
/** returns a new object with properties coming from two given objects */ | |
const merge = <T extends object, S extends object>(first: T, second: S): T & S => { | |
const res: Partial<T & S> = {}; | |
for (const prop in first) | |
if (first.hasOwnProperty(prop)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Button</title> | |
<link href="https://fonts.googleapis.com/css?family=Raleway:600&display=swap" rel="stylesheet"> | |
</head> | |
<style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Button</title> | |
<link href="https://fonts.googleapis.com/css?family=Raleway&display=swap" rel="stylesheet"> | |
</head> |