Skip to content

Instantly share code, notes, and snippets.

View day02's full-sized avatar

day day02

View GitHub Profile
#include <memory>
#include <string>
#include <iostream>
using salary_t = std::uint32_t;
struct user
{
user(const std::string &name);
~user();
#include <iostream>
#include <string>
#include <boost/signals2.hpp>
template<typename T>
struct observable
{
void subscribe(const auto&& observer)
{
m_field_changed.connect(observer);
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
template<typename T>
struct observer
{
// callback required
virtual void field_changed(T &source, const std::string &field_name) = 0;
#include <utility>
struct MyType
{
[[nodiscard]] MyType() {}
};
template <typename T, typename ... Args>
[[nodiscard]] T* create(Args&& ... args)
#include <iostream>
#include <memory>
#include <vector>
struct memento
{
std::int32_t m_balance{};
memento(const std::int32_t balance) : m_balance(balance) {}
};
#include <iostream>
#include <vector>
struct point
{
int m_x{};
int m_y{};
point(const int x, const int y) : m_x(x), m_y(y){}
// Example program
#include <iostream>
#include <string>
#include <cmath>
struct point
{
struct factory
{
static point cartesian(const double x, const double y) { return point(x, y); }
#include <iostream>
#include <string>
#include <map>
#include <memory>
enum class point_t
{
point_2D,
point_3D
};
#include <functional>
#include <iostream>
template <typename T>
struct logger;
// return type and argument list
template <typename return_t, typename... Args>
struct logger<return_t (Args...)>
{
// Flyway Design Pattern is quite simply a space optimization technique. That allows you to use less memory by storing some of the common data to several items or several objects.
#include <boost/flyweight.hpp>
#include <string>
#include <iostream>
using namespace std;
struct user {
user(const std::string &first_name, const std::string &last_name) : m_first_name(first_name), m_last_name(last_name) {}