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 <utility> | |
#ifndef SCOPE_EXIT_H_ | |
#define SCOPE_EXIT_H_ | |
// modeled slightly after Andrescu’s talk and article(s) | |
namespace std { | |
namespace experimental { | |
template <typename EF> struct scope_exit { | |
// construction |
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 <cstdio> | |
int main() { | |
int a = 810092048, b = a, c[] = {'\n\0i%','ziF\0', 'uB\0z', 'F\0zz', 'Bzzi', 'zzu'}; | |
for (int d = 1; d <= 100; ++d, b = (b >>= 2) ? b : a) { | |
std::printf((char*)c+(b&3)*5, d); std::printf((char*)c+3); | |
} | |
} |
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 <windows.web.http.h> | |
#include <windows.foundation.h> // ABI::Windows::Foundation::I* | |
#include <wrl/wrappers/corewrappers.h> //Microsoft::WRL::Wrappers | |
#include <wrl/client.h> // ComPtr | |
#include <stdexcept> | |
int main() { | |
Microsoft::WRL::Wrappers::RoInitializeWrapper initialize(RO_INIT_MULTITHREADED); |
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 <random> | |
#include <algorithm> | |
#include <iterator> | |
#include <numeric> | |
#include <iomanip> | |
#include <string> | |
int main(int argc, char *argv[]) { | |
if (argc < 2 || argv[1] == "--help" || argv[1] == "-h") { |
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
%VC12HOME%\vcvarsall.bat amd64 | |
%VC12HOME%\vcvarsall.bat | |
%VC11HOME%\vcvarsall.bat amd64 | |
%VC11HOME%\vcvarsall.bat | |
%VC10HOME%\vcvarsall.bat amd64 | |
%VC10HOME%\vcvarsall.bat | |
%VC9HOME%\vcvarsall.bat amd64 | |
%VC9HOME%\vcvarsall.bat | |
%VC8HOME%\vcvarsall.bat amd64 | |
%VC8HOME%\vcvarsall.bat |
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
--[[ | |
http://howardhinnant.github.io/date_algorithms.html | |
Returns number of days since civil 1970-01-01. Negative values indicate | |
days prior to 1970-01-01. | |
Preconditions: y-m-d represents a date in the civil (Gregorian) calendar | |
m is in [1, 12] | |
d is in [1, last_day_of_month(y, m)] | |
y is "approximately" in | |
[numeric_limits<Int>::min()/366, numeric_limits<Int>::max()/366] |
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 3.3) | |
project(lua VERSION 5.3.2 LANGUAGES C CXX) | |
set(LIB_SOURCE src/lapi.c src/lauxlib.c src/lbaselib.c src/lbitlib.c | |
src/lcode.c src/lcorolib.c src/lctype.c src/ldblib.c | |
src/ldebug.c src/ldo.c src/ldump.c src/lfunc.c src/lgc.c | |
src/linit.c src/liolib.c src/llex.c src/lmathlib.c src/lmem.c | |
src/loadlib.c src/lobject.c src/lopcodes.c src/loslib.c | |
src/lparser.c src/lstate.c src/lstring.c src/lstrlib.c | |
src/ltable.c src/ltablib.c src/ltm.c src/lundump.c |
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 <random> | |
#include <cassert> | |
#include <cstdint> | |
template< typename T, typename F, typename DF > | |
T newton(T x, F f, DF df) | |
{ | |
using std::abs; | |
T y = f(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
#include <iostream> | |
#include <random> | |
#include <cassert> | |
#include <cstdint> | |
static int odd_bits(std::uint64_t i) { | |
auto a = (0xFFFFFFFFu & i) ^ (i >> 32); | |
auto b = (0x0000FFFFu & a) ^ (a >> 16); | |
auto c = (0x000000FFu & b) ^ (b >> 8); | |
auto d = (0x0000000Fu & c) ^ (c >> 4); |
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 <future> | |
#include <atomic> | |
#include <iostream> | |
#include <vector> | |
#include <chrono> | |
template<typename Clock> | |
typename Clock::duration | |
check_clock_resolution() { | |
auto s = Clock::now(); |