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 / TestOpAssign.cpp
Created Sep 29, 2012
Performance test of X& operator=(X)
View TestOpAssign.cpp
/*
* TestOpAssign.cpp
*
* Created by Martin on 28 September 2012.
* Copyright 2012 Universiteit Leiden. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
@martinmoene
martinmoene / TestOpAssign_Niels_Martin.cpp
Created Oct 2, 2012
Performance test of X& operator=(X?)
View TestOpAssign_Niels_Martin.cpp
/*
* TestOpAssign_Niels_Martin.cpp
*
* Created by Martin on 28 September 2012.
* Adapted by Niels Dekker, 1 Oct 2012
* Copyright 2012 Universiteit Leiden. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
@martinmoene
martinmoene / TestOpAssign-variations.cpp
Created Oct 4, 2012
Variations on Performance test of X& operator=(X?)
View TestOpAssign-variations.cpp
/*
* TestOpAssign-variations-variations.cpp
*
* Created by Martin on 4 October 2012.
* Copyright 2012 Universiteit Leiden. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
@martinmoene
martinmoene / DynLibString.cpp
Last active Dec 15, 2015
A String class to use over a DLL boundary, enabling the use of different compiler versions at both ends.
View DynLibString.cpp
//
// Note: use _bstr_t. It's part of COM and present in VC6 and newer versions of Visual C++.
// It's an encapsulation of the BSTR string type that has a shared *C* API. It's used for
// interlanguage operability, so going between compiler/library versions is *not* a problem.
//
// Thanks to the kind people on the accu-general mailing list of http://accu.org/
//
//============================================================================
// String.h
@martinmoene
martinmoene / InsertionOpDetector.cpp
Last active Dec 16, 2015
Check for global operator<< for GCC 4.7.2, lang 3.1, VC2010, VC8, VC6
View InsertionOpDetector.cpp
// http://stackoverflow.com/a/5771273/437272
#include <iosfwd>
namespace detail {
typedef char no;
typedef char yes[2];
struct any_t {
@martinmoene
martinmoene / catch_tostring.cpp
Last active Dec 16, 2015
CATCH to_string based on CATCH v0.9 build 33, with different has_insertion_operator<>. 1. 'direct' tranfer from catch_tostring.hpp. 2. Replaced stream inserter detection with has_insertion_operator<>. 3. Added conditional changes for VC6.
View catch_tostring.cpp
// Notes at bottom.
// catch_common.h -----------------------------
#ifndef TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
#define TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
#define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
@martinmoene
martinmoene / gist:9091556
Created Feb 19, 2014
element_or(), container_element_or()
View gist:9091556
// element_or()
// container_element_or()
#include <map>
#include <vector>
/**
* return element of vector if present, def otherwise.
*/
template< typename E, typename I, typename D >
@martinmoene
martinmoene / gist:9410391
Created Mar 7, 2014
std::between() an idea by Niels Dekker
View gist:9410391
// std::between() an idea by Niels Dekker
#include <functional>
namespace std {
template<class T>
bool between(T const& val, T const& lo, T const& hi)
{
return between( val, lo, hi, std::less<T>() );
View gist:9485071
// [std-proposals] Using the underscore for unused identifiers
// https://groups.google.com/a/isocpp.org/d/msg/std-proposals/a4CRu2KONZ8/N0aPF76B990J
#include <iostream>
// _, or ANON
#define with( expr ) if ( auto&& _ = (expr) )
struct wither
{
View lest_sections.cpp
// lest light-weight sections
// [1] Catch: Test cases and sections,
// https://github.com/philsquared/Catch/blob/develop/docs/tutorial.md#test-cases-and-sections
// [2] lest – lest errors escape testing,
// https://github.com/martinmoene/lest#lest--lest-errors-escape-testing---10
#include <cassert>
#include <iostream>
You can’t perform that action at this time.