Skip to content

Instantly share code, notes, and snippets.

View Manu343726's full-sized avatar

Manu Sánchez Manu343726

View GitHub Profile
@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;

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 / 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
@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 / backward-cpp-valgrind-output.txt
Created September 9, 2016 11:54
Valgrind showing backward-cpp memory leaks when running siplasplas tests
3 FAILED TESTS
==7554==
==7554== HEAP SUMMARY:
==7554== in use at exit: 87,808 bytes in 60 blocks
==7554== total heap usage: 9,511 allocs, 9,451 frees, 1,600,428 bytes allocated
==7554==
==7554== 768 bytes in 3 blocks are definitely lost in loss record 1 of 4
==7554== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7554== by 0x4C2CF1F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7554== by 0x5A3B5B3: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22)
@Manu343726
Manu343726 / siplasplas-reflection.log.txt
Created May 22, 2016 15:20
Standardese assertion at cpp_namespace.cpp:52 failed
[ 83%] Built target standardese-external-project
[100%] Running Standardese on siplasplas-reflection headers...
[info] Generating documentation for "/home/manu343726/Documentos/siplasplas/include/siplasplas/reflection/dynamic/entity.hpp"...
[warning] Unknown cursor kind 'UnexposedDecl'
[warning] Unknown cursor kind 'UnexposedDecl'
[info] Generating documentation for "/home/manu343726/Documentos/siplasplas/include/siplasplas/reflection/dynamic/runtime.hpp"...
[info] Generating documentation for "/home/manu343726/Documentos/siplasplas/include/siplasplas/reflection/dynamic/detail/runtime_forward.hpp"...
[info] Generating documentation for "/home/manu343726/Documentos/siplasplas/include/siplasplas/reflection/dynamic/object.hpp"...
[info] Generating documentation for "/home/manu343726/Documentos/siplasplas/include/siplasplas/reflection/dynamic/api.hpp"...
[info] Generating documentation for "/home/manu343726/Documentos/siplasplas/in
@Manu343726
Manu343726 / standardese.log.txt
Created May 21, 2016 21:40
Standardese output on siplasplas allocator sources
/usr/bin/cmake -H/home/manu343726/Documentos/siplasplas -B/home/manu343726/Documentos/siplasplas/build --check-build-system CMakeFiles/Makefile.cmake 0
CMake Warning (dev) at 3rdParty/cmake/boost/blocks/boost/install/install.cmake:12 (set):
Cannot set "SCOPE": current scope has no parent.
Call Stack (most recent call first):
3rdParty/cmake/boost.cmake:13 (include)
cmake/deftargets.cmake:4 (include)
CMakeLists.txt:14 (include)
This warning is for project developers. Use -Wno-dev to suppress it.
-- SIPLASPLAS THIRD PARTY LIBRARY chaiscript
#include <vector>
#include <utility>
#include <algorithm>
void update(std::vector<bool>& map, std::size_t rows, std::size_t columns, bool(*rules)(std::size_t, bool))
{
auto at = [](std::size_t row, std::size_t column)
{
return row * columns + column;
};
@Manu343726
Manu343726 / gist:ca0ceb224ea789415387
Created September 19, 2015 18:15
Running ARM docker image with QEMU on x86_64 Arch Linux host
# Install quemu, docker, etc
yaourt -S qemu qemu-user-static binfmt-support
# The quemu-user-static AUR package is outdated and broken. The .deb package they pull is no longer in the ubuntu repository.
# Edit the PKGBUILD and use qemu-user-static_2.4+dfsg-3_amd64.deb (With SHA1 sum "84d83a16c60c82b6c579f2f750b04a3ac26c249b")
# Enable ARM emulation
update-binfmts --enable qemu-arm
@Manu343726
Manu343726 / vs_source_groups.cmake
Last active September 18, 2015 23:27
CMake script to generate Visual Studio source groups with the same structure as the project folder hierarchy
function(_generate_vs_source_groups GROUP_NAME TOP_DIRECTORY CURRENT_SUBDIRECTORY RESULT_FILES)
file(GLOB headers
${TOP_DIRECTORY}/${CURRENT_SUBDIRECTORY}/*.h
${TOP_DIRECTORY}/${CURRENT_SUBDIRECTORY}/*.hpp
${TOP_DIRECTORY}/${CURRENT_SUBDIRECTORY}/*.hh
${TOP_DIRECTORY}/${CURRENT_SUBDIRECTORY}/*.hxx
)