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 <cstdio> // printf | |
| struct mytype { | |
| int value; | |
| operator int() const {return value;} | |
| }; | |
| template<typename T> struct argument_type_helper{using type = T;}; | |
| template<> struct argument_type_helper<mytype>{using type = int;}; |
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 <atomic> | |
| #include <chrono> | |
| #include <ctime> | |
| #include <fstream> | |
| #include <iomanip> | |
| #include <ios> | |
| #include "Log.h" | |
| namespace Aux { namespace Log { |
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
| 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 |
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 <atomic> | |
| #include <chrono> | |
| #include <ctime> | |
| #include <fstream> | |
| #include <iomanip> | |
| #include <ios> | |
| #include "Log.h" | |
| namespace Aux { namespace Log { |
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 <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); | |
| } | |
| } | |
| }; |
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> | |
| 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; | |
| } |
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 <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) { |
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 <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)...)); |
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> | |
| int main() { | |
| for(int i=0; i < 10; ++i) { | |
| std::cout << "Hello World\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
| 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); |