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
@oliora
oliora / safe_advance.h
Last active Sep 26, 2019
Implementation of safe std::advance, std::next and std::prev similar to proposed N4317 paper "New Safer Functions to Advance Iterators"
View safe_advance.h
// N4317 "New Safer Functions to Advance Iterators" paper can be found at
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4317.pdf
namespace detail {
template<class InputIter>
inline void do_advance(InputIter& it, InputIter end, typename std::iterator_traits<InputIter>::difference_type n, std::input_iterator_tag)
{
assert(n >= 0);
for (; (n > 0) && (it != end); --n)
++it;
View make_vector.hpp
// make_vector.hpp
//
// Copyright (c) 2019 Tristan Brindle (tcbrindle at gmail dot com)
// Distributed under the Boost Software License, Version 1.0. (See
// http://www.boost.org/LICENSE_1_0.txt)
#include <type_traits>
#include <vector>
namespace tcb {
@shafik
shafik / WhatIsStrictAliasingAndWhyDoWeCare.md
Last active Nov 14, 2019
What is Strict Aliasing and Why do we Care?
View WhatIsStrictAliasingAndWhyDoWeCare.md

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th

@mbinna
mbinna / effective_modern_cmake.md
Last active Nov 15, 2019
Effective Modern CMake
View effective_modern_cmake.md

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

View Free O'Reilly Books.md

Free O'Reilly books and convenient script to just download them.

Thanks /u/FallenAege/ and /u/ShPavel/ from this Reddit post

How to use:

  1. Take the download.sh file and put it into a directory where you want the files to be saved.
  2. cd into the directory and make sure that it has executable permissions (chmod +x download.sh should do it)
  3. Run ./download.sh and wee there it goes. Also if you do not want all the files, just simply comment the ones you do not want.
@VictorLaskin
VictorLaskin / aop.cpp
Last active Oct 4, 2019
C++11 functional decomposition - easy way to do AOP
View aop.cpp
// This is example from
// http://vitiy.info/c11-functional-decomposition-easy-way-to-do-aop/
// by Victor Laskin
#include <iostream>
#include <functional>
#include <map>
#include <vector>
#include <memory>
#include <chrono>
@yamaya
yamaya / xcode-clang-vers
Last active Nov 14, 2019
Xcode clang version record
View xcode-clang-vers
# Xcode 4.3.3
Apple clang version 3.1 (tags/Apple/clang-318.0.61) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix
# Xcode 4.3.2
Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix
You can’t perform that action at this time.