C++ links: Coroutines
https://github.com/MattPD/cpplinks / C++ Standard / C++20 / Coroutines
(draft; work in progress)
#coroutines (C++ Slack): https://cpplang.slack.com/archives/C5JS5JXT5
CFLAGS = -std=c99 -Wall | |
main : main.o | |
.PHONY : test clean | |
test : main | |
./$^ "*regex*" "*vtable*" < main.c | |
clean : |
package main | |
import ( | |
"context" | |
"fmt" | |
"log" | |
"sync/atomic" | |
"go.opentelemetry.io/otel" | |
"go.opentelemetry.io/otel/metric" |
# Cleanup old alternatives | |
update-alternatives --remove-all cc | |
update-alternatives --remove-all c++ | |
update-alternatives --remove-all gcc | |
update-alternatives --remove-all g++ | |
update-alternatives --remove-all clang | |
update-alternatives --remove-all clang++ | |
update-alternatives --remove-all icc | |
update-alternatives --remove-all icc++ |
https://github.com/MattPD/cpplinks / C++ Standard / C++20 / Coroutines
(draft; work in progress)
#coroutines (C++ Slack): https://cpplang.slack.com/archives/C5JS5JXT5
class Solution { | |
public: | |
int compress(vector<char>& chars) { | |
int n = chars.size(); | |
if (n <= 1) return n; | |
int j = 0, i = 0; | |
while (i < n) { | |
int k = i; | |
// skip duplicates | |
while ((k + 1 < n) && chars[k] == chars[k + 1]) { |
string compression(const string & str){ | |
int i = str.size(); | |
string letters; | |
for (int j = 0; j < i; ++j){ | |
int count = 1; | |
while (str[j] == str[j+1]){ | |
count++; | |
j++; | |
} |
// based on https://stackoverflow.com/a/60080443 | |
#define RETURNS(...) \ | |
noexcept(noexcept(__VA_ARGS__)) \ | |
-> decltype(__VA_ARGS__) \ | |
{ return __VA_ARGS__; } | |
template<class T, | |
typename std::enable_if< !std::is_class<T>{}, bool>::type = true | |
> |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
/*- | |
* Copyright (c) 2014 Taylor R. Campbell | |
* 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 |
/* Copyright (c) 2018 Arvid Gerstmann. */ | |
/* This code is licensed under MIT license. */ | |
#ifndef AG_RANDOM_H | |
#define AG_RANDOM_H | |
class splitmix | |
{ | |
public: | |
using result_type = uint32_t; | |
static constexpr result_type (min)() { return 0; } |