Skip to content

Instantly share code, notes, and snippets.

View Fiona-J-W's full-sized avatar

Fiona Johanna Weber Fiona-J-W

View GitHub Profile
/*
* This file is part of vaporpp.
*
* vaporpp is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* vaporpp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
/*
* This file is part of vaporpp.
*
* vaporpp is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* vaporpp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@Fiona-J-W
Fiona-J-W / gist:5834452
Last active December 18, 2015 19:39 — forked from anonymous/gist:5834419
template<Strategy>
class Algorithm {
friend class ConcreteStrategy;
public:
Algorithm(ConcreteStrategy strategy) : strategy{strategy} {
strategy.set_algorithm(this);
}
void onEvent(Event x) {
this->strategy.onEvent(x);
#include <iostream>
int main() {
for(int i=0; i < 10; ++i) {
std::cout << "Hello World\n";
}
}
#include <cmath>
#include <cstddef>
#include <iostream>
#include <memory>
#include <utility>
#include <vector>
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
@Fiona-J-W
Fiona-J-W / main.cpp
Last active December 31, 2015 23:59
#include <cmath>
#include <cstddef>
#include <iostream>
#include <memory>
#include <string>
#include <utility>
#include <vector>
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args) {
#include <iostream>
constexpr unsigned long long fib(unsigned n) {
return n <= 1 ? 1 : fib(n-1) + fib(n-2);
}
int main() {
auto fib50 = fib(50);
std::cout << fib50 << std::endl;
}
#include <type_traits>
template<unsigned Depth, typename Container, typename Function>
struct deep_for_each_helper {
static void deep_for_each(Container& cont, const Function& fun) {
for(auto& elem: cont) {
deep_for_each_helper<Depth-1, typename std::decay<decltype(elem)>::type, Function>::deep_for_each(elem, fun);
}
}
};
#include <atomic>
#include <chrono>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <ios>
#include "Log.h"
namespace Aux { namespace Log {
clang++ -O0 -Wextra -pedantic -std=c++11 -D_GLIBCXX_DEBUG -g -c -o main.o src/test/main.cpp
In file included from src/test/main.cpp:1:
src/test/../lib/StringBuilder.h:95:2: error: static_assert failed "printToStream must not be called with an unprintable argument"
static_assert(getPrintableCategory<T>() != PrintableCategory::Unprintable,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/test/../lib/StringBuilder.h:232:3: note: in instantiation of function template specialization 'Aux::Impl::printToStream<Unprintable>' requested here
printToStream(stream, std::get<I-1>(arg));
^
src/test/../lib/StringBuilder.h:237:53: note: in instantiation of member function 'Aux::Impl::printTupleHelper<std::tuple<Unprintable>, 1, 1>::print'
requested here