static void D() { }
static void Y() { D(); }
static void X() { Y(); }
static void C() { D(); X(); }
static void B() { C(); }
static void S() { D(); }
static void P() { S(); }
static void O() { P(); }
static void N() { O(); }
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 <type_traits> | |
#include <any> | |
class AnyPointer { | |
public: | |
template <typename T, | |
typename = typename std::enable_if<std::is_pointer<typename std::remove_cv<T>::type>::value>::type> | |
AnyPointer(T ptr): any_(ptr) {} | |
template <typename ValueType> |
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
#pragma once | |
#include <string_view> | |
struct static_type_id { | |
static_type_id() = default; | |
constexpr static_type_id(const char* s, size_t len) | |
: name{s}, size{len}, hash{fnv1a_hash(len, s)} | |
{} | |
friend constexpr bool operator==(const static_type_id& lhs, const static_type_id& rhs) noexcept |
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
#pragma once | |
#include <stdint.h> | |
//fnv1a 32 and 64 bit hash functions | |
// key is the data to hash, len is the size of the data (or how much of it to hash against) | |
// code license: public domain or equivalent | |
// post: https://notes.underscorediscovery.com/constexpr-fnv1a/ | |
inline const uint32_t hash_32_fnv1a(const void* key, const uint32_t len) { |
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 <array> | |
#include <utility> | |
enum class SomeEnum : int { | |
item1 = 0, | |
item2, | |
item3, | |
size | |
}; |
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
cmake_minimum_required(VERSION 2.8) | |
set(CMAKE_INSTALL_PREFIX /usr) | |
project(UNITY_BUILD_NAME) | |
function(enable_unity_build UB_SUFFIX SOURCE_VARIABLE_NAME) | |
set(files ${${SOURCE_VARIABLE_NAME}}) | |
# Generate a unique filename for the unity build translation unit | |
set(unit_build_file ${CMAKE_CURRENT_BINARY_DIR}/ub_${UB_SUFFIX}.cpp) | |
# Exclude all translation units from compilation | |
set_source_files_properties(${files} PROPERTIES HEADER_FILE_ONLY true) |
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 <type_traits> | |
struct S; | |
template<typename T> | |
class test_complete_type { | |
T obj; | |
}; | |
template<typename T, typename = void> |
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 <cstring> // memcpy | |
#include <type_traits> // is_trivially_copyable | |
// http://src.chromium.org/viewvc/chrome/trunk/src/base/basictypes.h?view=markup | |
// bit_cast<Dest,Source> is a template function that implements the | |
// equivalent of "*reinterpret_cast<Dest*>(&source)". We need this in | |
// very low-level functions like the protobuf library and fast math | |
// support. | |
// |
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
These commands are based on a askubuntu answer http://askubuntu.com/a/581497 | |
To install gcc-6 (gcc-6.1.1), I had to do more stuff as shown below. | |
USE THOSE COMMANDS AT YOUR OWN RISK. I SHALL NOT BE RESPONSIBLE FOR ANYTHING. | |
ABSOLUTELY NO WARRANTY. | |
If you are still reading let's carry on with the code. | |
sudo apt-get update && \ | |
sudo apt-get install build-essential software-properties-common -y && \ | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \ |
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
// https://stackoverflow.com/questions/54786278/how-do-i-write-a-maintainable-fast-compile-time-bit-mask-in-c | |
#include <bitset> | |
enum Flags { A = 1, B = 2, C = 3, D = 5, | |
E = 8, F = 13, G = 21, H, | |
I, J, K, L, M, N, O }; | |
#define CPP_VERSION 14 | |
#if CPP_VERSION==11 |