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
#ifndef EXT_BACKTRACE_H | |
#define EXT_BACKTRACE_H 1 | |
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) | |
static void ext_log_backtrace() | |
{ | |
// TODO: backtrace not implemented | |
} |
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 <chrono> | |
int main() { | |
auto t0(std::chrono::steady_clock::now()); | |
// some code to measure time for | |
auto t1(std::chrono::steady_clock::now()); |
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> | |
int main() { | |
try { | |
// ... | |
} catch(_com_error &e) { | |
_bstr_t source(e.Source()); |
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 <string> | |
#include <locale> | |
#include <codecvt> | |
//UTF-8 to UTF-16 | |
std::string source; | |
//... | |
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,char16_t> convert; | |
std::u16string dest = convert.from_bytes(source); | |
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 <string> | |
#include <fstream> | |
int main() { | |
std::string filepath = "data.txt"; | |
std::ifstream ifs(filepath.c_str(), std::ios_base::in | std::ios_base::binary); | |
if (ifs) { |
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 <memory> | |
#include <functional> | |
#include <mutex> | |
template <typename T> | |
struct lazy { | |
public: | |
template <typename Fun> | |
explicit lazy(Fun&& fun) : fun(std::forward<Fun>(fun)) {} |
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 <boost/format.hpp> | |
inline std::string format_str_recursive(boost::format& message) { | |
return message.str(); | |
} | |
template<typename TValue, typename... TArgs> | |
std::string format_str_recursive(boost::format& message, TValue&& arg, TArgs&&... args) { | |
message % std::forward<TValue>(arg); |
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 <string> | |
#include <type_traits> | |
#include <typeinfo> | |
#include <tuple> | |
#include <functional> | |
template <typename T> | |
struct function_traits |
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 <vector> | |
// inline visitor | |
struct triangle; | |
struct square; | |
struct figure_visitor { | |
virtual ~figure_visitor() = default; | |
virtual void visit(const triangle&) {} |
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
function createMultimethod(dispatch, noMatch) { | |
if(typeof dispatch !== 'function') { | |
throw new TypeError('dispatch must be a function'); | |
} | |
const dict = {}; | |
if(typeof noMatch == 'function') { | |
dict.noMatch = noMatch; | |
} |
OlderNewer