Alternate title: yet another reason to loathe C++.
// foo.hpp
namespace root::foo {
// value categories, reference flavors, std::move() vs std::forward() | |
#include <string> | |
#include <vector> | |
struct Bar { | |
int *payload_; | |
Bar(); | |
~Bar(); |
// Word counter implemented with transform_reduce() | |
// Stolen from https://www.youtube.com/watch?v=LW_T2RGXego&t=571s | |
#include <iterator> | |
#include <functional> | |
#include <cctype> | |
#include <iostream> | |
#include <numeric> | |
#include <execution> |
// Templated constructor in derived class. | |
#include <utility> | |
struct B { | |
B(); | |
B(int); | |
B(const B&); |
// This program shows various ways of inserting and updating values in maps. | |
#include <unordered_map> | |
#include <string> | |
#include <cassert> | |
int main() { | |
std::unordered_map<std::string, int> m; | |
m.emplace("foo", 1); |
cmake_minimum_required(VERSION 3.11) | |
project(dummy_test_project) | |
set(CMAKE_CXX_STANDARD 17) | |
include(FetchContent) | |
FetchContent_Declare( | |
googletest | |
GIT_REPOSITORY https://github.com/google/googletest.git |
#include <sstream> | |
#include <iostream> | |
#include <boost/archive/binary_oarchive.hpp> | |
#include <boost/archive/binary_iarchive.hpp> | |
struct Foo { | |
int the_answer = 0; | |
double pi = 0.0; |
// How to check that callable passed to higher-order function has | |
// expected prototype in C++17 (pending C++20 concepts). | |
#include <type_traits> | |
#include <functional> | |
// Check with static_assert that F can be invoked with something convertible to int | |
// and returns something convertible to double. | |
template<class F> | |
double call(F f) { |
// Benchmark showing the impact of throwable move ctors when resizing a vector. | |
#include <vector> | |
#include <algorithm> | |
#include <iostream> | |
#include <benchmark/benchmark.h> | |
constexpr int PAYLOAD_SIZE = 1024; |