This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// element_or() | |
// container_element_or() | |
#include <map> | |
#include <vector> | |
/** | |
* return element of vector if present, def otherwise. | |
*/ | |
template< typename E, typename I, typename D > |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [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 | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C++11 - use multiple source files. | |
#include "lest.hpp" | |
lest::tests & specifications() | |
{ | |
static lest::tests tests; | |
return tests; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// replacing a loop (compute_loop()) with an std::algorithm. | |
#include <algorithm> | |
#include <functional> | |
#include <vector> | |
using Coll = std::vector<int>; | |
int compute_loop( Coll a, Coll b ) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#define sometimes if | |
bool is( std::string text ) | |
{ | |
return ! text.empty(); | |
} | |
std::string number( int x ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// simple running average (mean and median) of samples. | |
// | |
#include <algorithm> | |
#include <cassert> | |
#include <numeric> | |
#include <vector> | |
#ifndef RUNLENGTH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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) | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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) | |
*/ |
OlderNewer