Skip to content

Instantly share code, notes, and snippets.

View martinmoene's full-sized avatar

Martin Moene martinmoene

View GitHub Profile
@martinmoene
martinmoene / check_result.hpp
Created May 17, 2018 13:49
Kenny Kerr. Windows with C++ - C++ and the Windows API. July 2011.
/**
* \file win/check_result.h
*
* \brief Windows API.
* \author Kenny Kerr, Martin Moene
* \date 3 February 2016
* \since 0.0.0
*
* From: Kenny Kerr. Windows with C++ - C++ and the Windows API. July 2011.
* https://msdn.microsoft.com/%20magazine/hh288076
@martinmoene
martinmoene / pipe-godbolt-c++98.cpp
Last active December 15, 2017 23:14
Simple C++98 functional algorithms for optional-lite
// Simple C++98 functional algorithms for optional-lite
#include <functional>
#include <optional.hpp>
#define RESULT_OF_T(F) typename nonstd::optional_lite::detail::result_of<F>::type
// map(f): perform an operation `U f(T)` on optional's
// content if present and return an nonstd::optional<U>.
@martinmoene
martinmoene / catch-main.cpp
Last active September 6, 2017 01:43
CATCH - Small complete multi-file example.
// This tells Catch to provide a main() - only do this in one cpp file:
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
@martinmoene
martinmoene / catch-toclify.bat
Last active August 27, 2017 22:07
Create ToC in markdown files for Catch2 documentation
@echo off & setlocal enableextensions
::
:: ./Catch-toclify.bat - ... (https://github.com/rasbt/markdown-toclify)
::
if [%1] == [] goto :Usage
set files= %*%
set root=%~dp0
set toclify=%root%\markdown-toclify.py
@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 / PVS-Studio.txt
Last active July 21, 2017 07:40
lest Static Analyses
V813 Decreased performance. The 'message' argument should probably be rendered as a constant reference. 05-select lest.hpp 423
V813 Decreased performance. The 'message' argument should probably be rendered as a constant reference. 05-select lest.hpp 428
V813 Decreased performance. The 'type' argument should probably be rendered as a constant reference. 05-select lest.hpp 433
V813 Decreased performance. The 'words' argument should probably be rendered as a constant reference. 05-select lest.hpp 781
V813 Decreased performance. The 'word' argument should probably be rendered as a constant reference. 05-select lest.hpp 784
V813 Decreased performance. The 'note' argument should probably be rendered as a constant reference. 05-select lest.hpp 789
V813 Decreased performance. The 'test' argument should probably be rendered as a constant reference. 05-select lest.hpp 803
V813 Decreased performance. The 'whats', 'line' arguments should probably be rendered as constant references. 05-select lest.hpp 829
V813 Decreased p
@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 / 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-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]