Skip to content

Instantly share code, notes, and snippets.

View martinmoene's full-sized avatar

Martin Moene martinmoene

View GitHub Profile
@yamaya
yamaya / xcode-clang-vers
Last active April 3, 2024 02:28
Xcode clang version record
# 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
@VictorLaskin
VictorLaskin / aop.cpp
Last active November 17, 2021 12:28
C++11 functional decomposition - easy way to do AOP
// 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>
@ellerbrock
ellerbrock / Free O'Reilly Books.md
Last active January 10, 2024 16:14 — forked from augbog/Free O'Reilly Books.md
Free O'Reilly Books

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.
@mbinna
mbinna / effective_modern_cmake.md
Last active April 18, 2024 19:26
Effective Modern CMake

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

@shafik
shafik / WhatIsStrictAliasingAndWhyDoWeCare.md
Last active April 24, 2024 03:49
What is Strict Aliasing and Why do we Care?

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

@Leandros
Leandros / random.h
Created July 2, 2018 05:22
C++ Pseudo Random Number Generators
/* Copyright (c) 2018 Arvid Gerstmann. */
/* This code is licensed under MIT license. */
#ifndef AG_RANDOM_H
#define AG_RANDOM_H
class splitmix
{
public:
using result_type = uint32_t;
static constexpr result_type (min)() { return 0; }
// 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 {
@oliora
oliora / safe_advance.h
Last active September 26, 2019 02:38
Implementation of safe std::advance, std::next and std::prev similar to proposed N4317 paper "New Safer Functions to Advance Iterators"
// 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;