Skip to content

Instantly share code, notes, and snippets.

View facontidavide's full-sized avatar
🤓
Developing

Davide Faconti facontidavide

🤓
Developing
View GitHub Profile
@facontidavide
facontidavide / template_check_class_member.cpp
Created November 14, 2016 09:38
When using a template, check if the template argument has a specific method
#include <iostream>
#include <typeinfo>
struct Hello
{
int helloworld() { return 0; }
};
struct Generic {};
typedef struct{
time_t start_date; end_date;
std::string company_name;
std:.string responsibilities_and_achievements;
} PreviousJob;
typedef struct Candidate{
std::vector<PersonalityTraits> traits;
std::vector<boost::any > skills; // use boost::any as type erasure.
std::vector<PreviousJob> previous_jobs;
#include <atomic>
#include <chrono>
#include <deque>
#include <iostream>
#include <mutex>
#include <future>
#include <thread>
// shared stuff:
std::deque<std::packaged_task<void()>> tasks;
@facontidavide
facontidavide / factory.cpp
Last active November 16, 2022 09:16
Factory pattern in C++
#include <iostream>
#include <unordered_map>
#include <functional>
#include <vector>
// Base class
class Shape {
public:
virtual void draw() = 0;
};
@facontidavide
facontidavide / lz4_sample.cpp
Created May 26, 2016 11:08
Simple LZ4 example
#include "lz4.h"
using namespace std;
int main()
{
char szSource[] = "2013-01-07 00:00:04,0.98644,0.98676 2013-01-07 00:01:19,0.98654,0.98676 2013-01-07 00:01:38,0.98644,0.98696";
int nInputSize = sizeof(szSource);
// compress szSource into pchCompressed
@facontidavide
facontidavide / string_buffer.cpp
Last active October 30, 2015 22:52
StringBuffer
/*
(c) 2013 +++ Filip Stoklas, aka FipS, http://www.4FipS.com +++
THIS CODE IS FREE - LICENSED UNDER THE MIT LICENSE
ARTICLE URL: http://forums.4fips.com/viewtopic.php?f=3&t=1075
*/
#include <array>
#include <cassert>
#include <stdarg.h> // va_list
#define WIN32_LEAN_AND_MEAN