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 / main.cpp
Last active Jun 7, 2019
Converting endianness (C++11) - inspired by https://github.com/MayaPosch/ByteBauble
View main.cpp
#include "nonstd/endian.hpp"
#include <iostream>
#define print_to_big_endian(x) \
std::cout << #x << ": " << std::hex << to_num(x) << " to be: " << to_num(nonstd::to_big_endian(x)) << "\n"
#define print_to_little_endian(x) \
std::cout << #x << ": " << std::hex << to_num(x) << " to le: " << to_num(nonstd::to_little_endian(x)) << "\n"
#define print_to_native_endian(x) \
@martinmoene
martinmoene / Jinja2Cpp-ParseError.cpp
Last active Apr 29, 2019
Jinja2Cpp: ParseError and assignment/swap -- Note: nonstd::expected uses swap() in operator=( expected const & other ).
View Jinja2Cpp-ParseError.cpp
//
// If you write
// ParseError(ParseError&& other) noexcept(true) = default;
// the type won't be treated as nothrow move-constructable.
// But if you write this ctor manually - everything is ok.
#include <initializer_list>
#include <utility>
#include <vector>
@martinmoene
martinmoene / app-state-machine.cpp
Last active Apr 17, 2019
C++17 example of user interface with state machine based on std::variant.
View app-state-machine.cpp
// C++17 example of user interface with state machine based on std::variant.
// The state machine engine is based on code by Mateusz Pusz,
// https://github.com/mpusz/fsm-variant (MIT-license)
// CppCon 2016. Ben Deane: Using Types Effectively,
// https://www.youtube.com/watch?v=ojZbFIQSdl8
//------------------------------------------------------------------------
// State machine engine:
@martinmoene
martinmoene / cmd.txt
Last active Oct 10, 2018
Compare number of lines in different Subversion revisions of files
View cmd.txt
# file1.cpp has code removed unintentionally:
> svn-diff-size.py --threshold -60 --histogram --revision 4710:4839 Folder/*.cpp
Folder/file1.cpp: (4317 -> 4136): -181
Folder/file2.cpp: (2323 -> 2145): -178
Folder/file2.cpp: (1031 -> 886): -145
Histogram delta line-count:
-200: 0
-180: 2 **
@martinmoene
martinmoene / check_result.hpp
Created May 17, 2018
Kenny Kerr. Windows with C++ - C++ and the Windows API. July 2011.
View check_result.hpp
/**
* \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 Dec 15, 2017
Simple C++98 functional algorithms for optional-lite
View pipe-godbolt-c++98.cpp
// 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-toclify.bat
Last active Aug 27, 2017
Create ToC in markdown files for Catch2 documentation
View catch-toclify.bat
@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 Jul 21, 2017
lest Static Analyses
View PVS-Studio.txt
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 / PVS-Studio.txt
Last active Jul 21, 2017
doctest Static Analyses (21 July 2017)
View PVS-Studio.txt
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 Jul 20, 2017
Catch-2 Static Analysis - 20170719 - 20170720 (PVS-Studio., ReSharper C++)
View Catch-2 Static Analysis
PVS-Studio 6.16
ReSharper C++ 2017.1.3
VC-CppCoreCheck-released (VS 2017)
You can’t perform that action at this time.