Skip to content

Instantly share code, notes, and snippets.

View Manu343726's full-sized avatar

Manu Sánchez Manu343726

View GitHub Profile
@Manu343726
Manu343726 / CMakeLists.txt
Created October 26, 2016 14:02
Configure protobuf with cmake
cmake_minimum_required(VERSION 3.4)
project(MyProject)
if(NOT MY_PROJECT_PROTOBUF_VERSION)
set(MY_PROJECT_PROTOBUF_VERSION 2.6.1)
endif()
option(MY_PROJECT_SHARED_LIBS "Build proto modules as shared libraries" OFF)
message(STATUS "Google Protocol Buffers version: ${MY_PROJECT_PROTOBUF_VERSION}")
@Manu343726
Manu343726 / cppp17_deduction_guides_meta.cpp
Last active January 18, 2017 00:42
Using C++17 template deduction guides as metafunctions. See http://melpon.org/wandbox/permlink/lVFBj7shPP0fUMuQ
#include <iostream>
#include <string>
#include <vector>
// Basic vocabulary first:
// A function
template<typename Result>
struct Function

A readonly string class

The objective of this exercise is to learn the basics of RAII, the most important pilar of C++. To do so, you must implement an inmutable string class, which works as follows:

  • The class belongs to the first module of the project, containers.
  • Can be initialized from a C null terminated string (const char*).
  • Manages its own copy in memory of the string given to the constructor.
  • The underlying string storage is correctly handled (Released when it needs to, copied when it needs to, etc).
  • The class has no mutable operations, so the underlying storage is modified only in initialization/copy/move/destruction operations.
@Manu343726
Manu343726 / enum++.hpp
Last active October 31, 2017 09:04
C++11 introspectable "enums"
#ifndef ENUMPP_HPP
#define ENUMPP_HPP
#include <initializer_list>
#include <utility>
#include <array>
#include <ostream>
template<typename T, std::size_t TotalValues>
struct Enum;
@Manu343726
Manu343726 / adl_sfinae.cpp
Created January 19, 2018 10:36
ADL-based SFINAE
namespace bitmasks_lib
{
std::false_type enableBitMaskOperators(type_tag<T>);
// use the result of this function as SFINAE predicate
template<typename T>
constexpr bool bitmaskOperatorsEnabled()
{
using bitmasks_lib::enableBitMaskOperators;
return decltype(enableBitMaskOperators(type_tag<T>()))::value;
@Manu343726
Manu343726 / genericrunnable.cpp
Created February 14, 2018 09:13
Generic QRunnable implementation
// Java sucks, and importing design patterns from Java sucks even more.
//
// This template avoids writing one QRunnable derived class per use case
// by wrapping any C++ callable.
template<typename Function>
struct Task : public QRunnable, Function
{
template<typename... Args>
Task(Args&&... args) :
@Manu343726
Manu343726 / input.hpp
Created March 23, 2018 11:08
tinyrefl generated code example
#include <QObject>
namespace wmip
{
namespace testing
{
class MyInterface : public QObject
{
@Manu343726
Manu343726 / gist:2d4523cb902a7919d45ec6d460a9f032
Created April 2, 2018 08:32
tinyrefl parser errors, no namespaces in global namespace found
Running with gitlab-runner 10.6.0 (a3543a27)
 on docker-auto-scale 72989761
Using Docker executor with image lasote/conangcc5 ...
Pulling docker image lasote/conangcc5 ...
Using docker image sha256:682660755d898a68a7b1d77543f2e736a6c554ccb436b5575057147871ec2f51 for lasote/conangcc5 ...
section_start:1522656548:prepare_script
Running on runner-72989761-project-5169630-concurrent-0 via runner-72989761-srm-1522656459-d4b13fb3...
section_end:1522656550:prepare_script
section_start:1522656550:get_sources
Cloning repository...
@Manu343726
Manu343726 / build.log
Created October 23, 2018 16:02
Jinja2Cpp build failure with conan (variant-lite namespace issue)
This file has been truncated, but you can view the full file.
Exporting package recipe
Linter warnings
WARN: Linter. Line 37: Undefined variable 'os'
WARN: Linter. Line 38: Undefined variable 'os'
WARN: Linter. Line 1: Unused tools imported from conans
jinja2cpp/master@Manu343726/testing: The stored package has not changed
Configuration:
[settings]
os=Linux
os_build=Linux
@Manu343726
Manu343726 / using_value_ptr_lite_0.1.0.log
Created October 24, 2018 12:31
Jinja2Cpp conan package build logs
This file has been truncated, but you can view the full file.
Exporting package recipe
Linter warnings
WARN: Linter. Line 37: Undefined variable 'os'
WARN: Linter. Line 38: Undefined variable 'os'
WARN: Linter. Line 1: Unused tools imported from conans
jinja2cpp/master@Manu343726/testing: The stored package has not changed
Configuration:
[settings]
os=Linux
os_build=Linux