Skip to content

Instantly share code, notes, and snippets.

@kris-jusiak
kris-jusiak / bench_generators.cpp
Last active February 4, 2024 08:40
Simple generators benchmark
// https://godbolt.org/z/b9s5cxPao
#include <generator>
#include <utility>
auto generator_baseline() -> int {
static THREAD_LOCAL auto i = 0;
return i++;
}
//
// Copyright (c) 2022 Kris Jusiak (kris at jusiak dot net)
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
//
// Usage
// #![feature(specialization)]
// #![allow(incomplete_features)]
/*
Arduino.h - Main include file for the Arduino SDK
Copyright (c) 2005-2013 Arduino Team. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
//
// Copyright (c) 2018 Kris Jusiak (kris at jusiak dot net)
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#if not defined(__cpp_variadic_templates) or \
not defined(__cpp_rvalue_references) or not defined(__cpp_decltype) or \
static int version = 42;
//
// Copyright (c) 2016-2017 Kris Jusiak (kris at jusiak dot net)
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#include <utility>
#if (__cplusplus < 201305L && _MSC_VER < 1900)
//
// Copyright (c) 2016-2017 Kris Jusiak (kris at jusiak dot net)
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#include <utility>
#if (__cplusplus < 201305L && _MSC_VER < 1900)
//
// Copyright (c) 2016-2017 Kris Jusiak (kris at jusiak dot net)
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#include <utility>
#if (__cplusplus < 201305L && _MSC_VER < 1900)
//
// Copyright (c) 2016-2018 Kris Jusiak (kris at jusiak dot net)
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#if (__cplusplus < 201305L && _MSC_VER < 1900)
#error "[Boost].SML requires C++14 support (Clang-3.4+, GCC-5.1+, MSVC-2015+)"
#else
This file has been truncated, but you can view the full file.
#include <type_traits>
template<typename...Ts>
struct list {};
template<int I>
struct generator;
template<>
struct generator<9> {