Skip to content

Instantly share code, notes, and snippets.

View martinmoene's full-sized avatar

Martin Moene martinmoene

View GitHub Profile
@martinmoene
martinmoene / PVS-Studio.txt
Last active July 21, 2017 09:10
doctest Static Analyses (21 July 2017)
V794 The copy operator should be protected from the case of 'this == &other'. all_features doctest.h 574
V690 Copy constructor is declared as private in the 'ContextBuilder' class, but the default '=' operator will still be generated by compiler. It is dangerous to use such a class. all_features doctest.h 1834
V730 Not all members of a class are initialized inside the constructor. Consider inspecting: stackChunks. all_features doctest.h 1897
V794 The copy operator should be protected from the case of 'this == &other'. all_features doctest.h 3574
V530 The return value of function 'LoadLibraryA' is required to be utilized. executable_dll_and_plugin main.cpp 48
V794 The copy operator should be protected from the case of 'this == &other'. playground doctest_fwd.h 571
V690 Copy constructor is declared as private in the 'ContextBuilder' class, but the default '=' operator will still be generated by compiler. It is dangerous to use such a class. playground doctest_fwd.h 1831
V730 Not all members of a class are initi
@martinmoene
martinmoene / Catch-2 Static Analysis
Last active July 20, 2017 21:18
Catch-2 Static Analysis - 20170719 - 20170720 (PVS-Studio., ReSharper C++)
PVS-Studio 6.16
ReSharper C++ 2017.1.3
VC-CppCoreCheck-released (VS 2017)
@martinmoene
martinmoene / CppCheck.txt
Last active July 20, 2017 15:10
Catch-1 Static Analysis
..\..\..\..\..\..\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 22:43
C++ option handling without dedicated library
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 January 8, 2016 10:33
EXPECT_ABORTS for lest test framework (C++11) - substitute ::abort(), throw
// 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 January 11, 2016 12:12
EXPECT_ABORTS for lest test framework (C++11) - substitute ::abort(), longjmp()
// 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 January 8, 2016 09:36
EXPECT_ABORTS for lest test framework (C++11) - longjmp from signal handler
// 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 December 13, 2015 19:59
ePub - Create Overload 130 ePub from HTML sources
@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 November 9, 2015 13:32
Apples and bears
#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 September 15, 2015 05:27
Simple running average (mean and median) of samples in C++.
//
// simple running average (mean and median) of samples.
//
#include <algorithm>
#include <cassert>
#include <numeric>
#include <vector>
#ifndef RUNLENGTH