Instantly share code, notes, and snippets.

# Vittorio RomeoSuperV1234

• Sort options
Created Jan 18, 2012
Euler's totient function phi --- a fast implementation in C++
View euler_phi.cpp
 /* * Euler's totient function phi(n). * http://en.wikipedia.org/wiki/Euler%27s_totient_function * * This is an *EXTREMELY* fast function and uses * several tricks to recurse. * * It assumes you have a list of primes and a fast * isprime() function. Typically, you use a bitset * to implement the sieve of Eratosthenes and use
Last active Dec 11, 2018
Lua C++ wrapper. C++11 templates street magic.
View Lua.cc
 #include extern "C" { #include #include }; using namespace util; int Lua::call(lua_State *vm) {
Last active Jul 22, 2020
C++11 variadic template class for C# equivalent of delegates.
View delegate.hpp
 #ifndef DELEGATE_HPP_INCLUDED #define DELEGATE_HPP_INCLUDED #include #include // general case template class delegate {
Last active Mar 2, 2020
Don Clugston's fast delegate C++11 implementation
View FastFunc.hpp
 #ifndef SSVU_FASTFUNC #define SSVU_FASTFUNC #include #include #include #include #include #include #include
Created Sep 13, 2014
Implement static_if using C11 generic selection
View static_if.cc
 #include #include #include // Link: https://github.com/aeyakovenko/notes //count arguments //COUNT_ARGS :: ... -> Int #define COUNT_ARGS(...) COUNT_ARGS_(,##__VA_ARGS__,6,5,4,3,2,1,0) #define COUNT_ARGS_(z,a,b,c,d,e,f,cnt,...) cnt
Last active Jun 23, 2020
Addresses common issues with C++11 random number generation; makes good seeding easier, and makes using RNGs easy while retaining all the power.
View randutils.hpp
 /* * Random-Number Utilities (randutil) * Addresses common issues with C++11 random number generation. * Makes good seeding easier, and makes using RNGs easy while retaining * all the power. * * The MIT License (MIT) * * Copyright (c) 2015 Melissa E. O'Neill *
Last active Jul 7, 2020