This file contains hidden or 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 <cmath> | |
#include <iostream> | |
int main() { | |
double num1 = 1.4126572077159485e+23; | |
double num2 = 1.4126572077159483546e+23; | |
double num3 = std::nexttoward(num2, num1); | |
std::cout << (num3 > num2) << '\n'; | |
} |
This file contains hidden or 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
#ifndef ENFORCE_H_ | |
#define ENFORCE_H_ | |
#include <cassert> | |
#include <stdexcept> | |
#include <string> | |
namespace Aux { | |
/** |
This file contains hidden or 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 <utility> | |
template<typename Handle, class Releaser> | |
Handle get_null_handle() { | |
return Handle{}; | |
} | |
template<typename Handle, typename Releaser> |
This file contains hidden or 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 <algorithm> | |
#include <string> | |
#include <iostream> | |
#include <iterator> | |
#include <cstdint> | |
int main() { | |
std::string line; | |
while(std::getline(std::cin, line)) { | |
std::size_t inversions = 0; |
This file contains hidden or 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 <cassert> | |
#include <iostream> | |
enum class side { | |
good, | |
evil | |
}; | |
enum class strength { | |
strong, |
This file contains hidden or 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 <cassert> | |
#include <chrono> | |
#include <iostream> | |
#include <limits> | |
#include <random> | |
#include <sstream> | |
#include <string> | |
#include <tuple> | |
#include <type_traits> |
This file contains hidden or 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
set nu | |
set tabstop=8 | |
set shiftwidth=8 | |
" many thanks to steve losh. his blogpost at | |
" http://stevelosh.com/blog/2010/09/coming-home-to-vim |
This file contains hidden or 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 <tuple> | |
#include <istream> | |
template<unsigned Index, unsigned Max, typename Tuple> | |
struct read_tuple_helper { | |
static void read(std::istream& stream, Tuple& tuple) { | |
stream >> std::get<Index>(tuple); |
This file contains hidden or 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 <utility> | |
struct foobar{ | |
std::string value = "fooabarbazquux"; | |
foobar() = default; | |
foobar(const foobar& other): value{other.value} { | |
std::cout << "foobar(const foobar&)\n"; | |
} |
This file contains hidden or 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 <type_traits> | |
template<bool B, unsigned Index, template<typename> class Predicate, typename...Tail> | |
struct find_if_helper2; | |
template<template<typename> class Predicate, unsigned Index, typename Head, typename...Tail> | |
struct find_if_helper1{ | |
using type = typename find_if_helper2<Predicate<Head>::value, Index, Predicate, Tail...>::type; | |
}; |