Skip to content

Instantly share code, notes, and snippets.

🔆
daily grind

Martin Moene martinmoene

🔆
daily grind
Block or report user

Report or block martinmoene

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@martinmoene
martinmoene / CppCheck.txt
Last active Jul 20, 2017
Catch-1 Static Analysis
View CppCheck.txt
..\..\..\..\..\..\Local\Project\_GitHub\Catch\single_include\catch.hpp|1595|unusedStructMember : style : struct member 'FalseType::sizer' is never used.|
..\..\..\..\..\..\Local\Project\_GitHub\Catch\single_include\catch.hpp|503|noExplicitConstructor : style : Class 'NotImplementedException' has a constructor with 1 argument that is not explicit. Such constructors should in general be explicit for type safety reasons. Using the explicit keyword in the constructor means some mistakes when using the class can be avoided.|
..\..\..\..\..\..\Local\Project\_GitHub\Catch\single_include\catch.hpp|564|noExplicitConstructor : style : Class 'Ptr' has a constructor with 1 argument that is not explicit. Such constructors should in general be explicit for type safety reasons. Using the explicit keyword in the constructor means some mistakes when using the class can be avoided.|
..\..\..\..\..\..\Local\Project\_GitHub\Catch\single_include\catch.hpp|704|noExplicitConstructor : style : Class 'MethodTestCase' has a constructo
@martinmoene
martinmoene / non-library-option-example.h
Last active May 21, 2018
C++ option handling without dedicated library
View non-library-option-example.h
using text = std::string;
using texts = std::vector<text>;
inline auto split_option( text arg ) -> std::tuple<text, text>
{
auto pos = arg.rfind( '=' );
return pos == text::npos
? std::make_tuple( arg, "" )
: std::make_tuple( arg.substr( 0, pos ), arg.substr( pos + 1 ) );
@martinmoene
martinmoene / main-own-abort.cpp
Last active Jan 8, 2016
EXPECT_ABORTS for lest test framework (C++11) - substitute ::abort(), throw
View main-own-abort.cpp
// Death test for abort/assert - substitute ::abort()
//
// Expect_aborts succeeds for std::abort() [pass]
// Expect_aborts succeeds for assert(false) [pass]
// Expect_aborts reports assert(true) [fail]
// Expect_aborts reports an unexpected standard exception [fail]
// Expect_aborts reports an unexpected non-standard exception [fail]
// Expect_no_abort succeeds for assert(true) [pass]
// Expect_no_abort reports std::abort() [fail]
// Expect_no_abort reports assert(false) [fail]
@martinmoene
martinmoene / main-own-abort.cpp
Last active Jan 11, 2016
EXPECT_ABORTS for lest test framework (C++11) - substitute ::abort(), longjmp()
View main-own-abort.cpp
// Death test for abort/assert - substitute ::abort()
//
// Expect_aborts succeeds for ::abort() [pass]
// Expect_aborts succeeds for std::abort() [pass]
// Expect_aborts succeeds for assert(false) [pass]
// Expect_aborts reports assert(true) [fail]
// Expect_aborts succeeds for assert(false) in user noexcept function [pass]
// Expect_aborts reports an unexpected standard exception [fail]
// Expect_aborts reports an unexpected non-standard exception [fail]
// Expect_no_abort succeeds for assert(true) [pass]
@martinmoene
martinmoene / main.cpp
Last active Jan 8, 2016
EXPECT_ABORTS for lest test framework (C++11) - longjmp from signal handler
View main.cpp
// Death test for abort/assert - divert std::abort
//
// Expect_aborts succeeds for std::abort() [pass]
// Expect_aborts succeeds for assert(false) [pass]
// Expect_aborts reports assert(true) [fail]
// Expect_aborts reports an unexpected standard exception [fail]
// Expect_aborts reports an unexpected non-standard exception [fail]
// Expect_no_abort succeeds for assert(true) [pass]
// Expect_no_abort reports std::abort() [fail]
// Expect_no_abort reports assert(false) [fail]
@martinmoene
martinmoene / mk-epub.bat
Created Dec 13, 2015
ePub - Create Overload 130 ePub from HTML sources
View mk-epub.bat
@echo off & setlocal
:: mk-epub title #issue date source
if [%4] == [] goto :Usage
set PANDOC=pandoc
set TO=epub
set TITLE=%~1
@martinmoene
martinmoene / apples.cpp
Last active Nov 9, 2015
Apples and bears
View apples.cpp
#include <iostream>
#include "phys/units/io.hpp"
#include "phys/units/quantity.hpp"
using namespace phys::units;
using namespace phys::units::io;
auto apple( unit( "apple", extend() ) );
auto box ( unit( "box" , extend() ) );
@martinmoene
martinmoene / main.cpp
Last active Sep 15, 2015
Simple running average (mean and median) of samples in C++.
View main.cpp
//
// simple running average (mean and median) of samples.
//
#include <algorithm>
#include <cassert>
#include <numeric>
#include <vector>
#ifndef RUNLENGTH
@martinmoene
martinmoene / clamp-range-v3.cpp
Created Aug 23, 2015
C++ example of proposed clamp() used with range-v3 library.
View clamp-range-v3.cpp
// clamp-range-v3
#include <iostream>
#include <clamp.hpp>
#include <range/v3/core.hpp>
#include <range/v3/view/iota.hpp>
#include <range/v3/view/remove_if.hpp>
#include <range/v3/view/transform.hpp>
@martinmoene
martinmoene / value-semantics-sean-parent.cpp
Created Aug 18, 2015
Code from talk: Inheritance Is The Base Class of Evil by Sean Parent at Going Native 2013
View value-semantics-sean-parent.cpp
// Sean Parent. Inheritance Is The Base Class of Evil. Going Native 2013
// Video: https://www.youtube.com/watch?v=bIhUE5uUFOA
// Code : https://github.com/sean-parent/sean-parent.github.io/wiki/Papers-and-Presentations
/*
Copyright 2013 Adobe Systems Incorporated
Distributed under the MIT License (see license at
http://stlab.adobe.com/licenses.html)
This file is intended as example code and is not production quality.
You can’t perform that action at this time.