Special Thanks to KacKLaPPen23 and iNViSiBiLiTi for making this guide possible and being generally excellent people!
Programming Duck PCBs with O2D is a notoriously shitty experience.
Luckily with O2D 1.10 and this guide it will be less shitty!
| #include <iostream> | |
| #include <string> | |
| #include <string_view> | |
| namespace impl { | |
| template<typename T> | |
| concept StringLike = requires(T t) { | |
| { t.data() } -> std::convertible_to<const char*>; | |
| { t.size() } -> std::convertible_to<std::size_t>; |
| template<typename T> struct type_id_impl { | |
| static int* loc() { | |
| static int i; | |
| return &i; | |
| } | |
| } | |
| template<typename T> type_id_t type_id() { | |
| return (type_id_t)&type_id_impl<T>::loc; | |
| } |
| #include <iostream> | |
| struct UserName { std::string name; }; | |
| struct Password { std::string pwd; }; | |
| template<typename T> | |
| auto peek(const T& packed) { | |
| static_assert(std::is_aggregate_v<T>, "Should be struct"); | |
| // we can further enforce T to have single field with | |
| const auto& [value] = packed; |
| #include <utility> | |
| #include <cstdio> | |
| template <typename ... Ts> | |
| constexpr auto tuple(Ts&& ... ts) | |
| { | |
| return [...ts = std::forward<Ts>(ts)](auto&& f) { return f(ts...);}; | |
| } | |
| template <unsigned I, typename T, typename ... Ts> |
| #include <exception> | |
| #include <stdexcept> | |
| #include <cstdio> | |
| #include <sstream> | |
| #include <iostream> | |
| template<class Ctx, class...Args> | |
| void rethrow(Ctx&& context, Args&&... args) | |
| { | |
| // build an error message |
| constexpr const char* end_of(const char* s) { | |
| while (*s != 0) ++s; | |
| return s; | |
| } | |
| struct cstr { | |
| const char* b_; | |
| const char* e_; | |
| constexpr cstr(const char* s) |
| #include <cmath> | |
| #include <limits> | |
| struct float_opt | |
| { | |
| float value_ = std::numeric_limits<float>::quiet_NaN(); | |
| explicit float_opt(float v): value_(v) {} | |
| constexpr float_opt() = default; |
| #include <memory> | |
| #include <utility> | |
| #include <cassert> | |
| #include <iostream> | |
| template<typename Service> | |
| struct Registry | |
| { | |
| Registry() = delete; | |
| ~Registry() = delete; |
| $ cat /tmp/quine.pl | |
| Illegal division by zero at /tmp/quine.pl line 1. | |
| $ perl /tmp/quine.pl | |
| Illegal division by zero at /tmp/quine.pl line 1. |