Skip to content

Instantly share code, notes, and snippets.

View nekko1119's full-sized avatar
🍙
nano!

nekko1119 nekko1119

🍙
nano!
View GitHub Profile
#include <Windows.h>
#include <vector>
#include <string>
BOOL utf8_to_sjis(BYTE* pSource, BYTE* pDist, int* pSize)
{
*pSize = 0;
//UTF-8 -> UTF-16
const int nSize = ::MultiByteToWideChar(CP_UTF8, 0, (LPCSTR) pSource, -1, NULL, 0);
#include <algorithm> // std::min
#include <cstddef> // std::size_t, std::ptrdiff_t
#include <iterator> // std::reverse_iterator
#include <stdexcept> // std::out_of_range
#include <utility> // std::index_sequence, std::forward
namespace experimental {
namespace detail {
constexpr std::size_t strlen(char const* str, std::size_t n) {
return *str ? strlen(++str, n + 1) : n;
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <functional>
#include <iostream>
#include <thread>
class printer
{
boost::asio::deadline_timer timer1;
boost::asio::deadline_timer timer2;
@nekko1119
nekko1119 / cpprun.bat
Created January 30, 2016 12:15
VSCodeの設定
@echo off
if "%~dpnx1" equ "" goto :eof
setlocal
set tempfile=%date:~4%%time::=%
set tempfile=%tempfile:/=%
set tempfile=%tempfile:.=%
set tempfile=%tempfile: =%
clang++ -o %tempfile%.exe "%~dpnx1" -std=c++1z
@nekko1119
nekko1119 / vtbl.cpp
Created December 17, 2015 15:53
仮想関数テーブルシミュレーション
#include <iostream>
class drawable
{
struct vtable
{
void(*draw)(void*);
};
template <typename T>
@nekko1119
nekko1119 / ando11.cpp
Last active December 12, 2015 04:51
パターンと完全一致する左上のピクセルの座標を半角スペース区切りで出力してください。パターンと完全一致する箇所は必ず1つだけ存在します。
/*
入力
4
0 0 1 0
0 1 1 0
0 1 0 1
1 1 1 0
3
0 1 1
0 1 0
@nekko1119
nekko1119 / group_by.cpp
Last active December 1, 2015 19:09
rubyのgroup_byをC++で書いてみた
#include <vector>
#include <numeric>
#include <unordered_map>
#include <iterator>
#include <functional>
#include <type_traits>
#include <utility>
template <typename T, typename A>
std::string to_string(std::vector<T, A> const& v);
constexpr int f() { return 0; }
constexpr int g();
static_assert(noexcept(f()), "");
static_assert(!noexcept(g()), "");
constexpr int h(bool b) { return b ? 0 : throw 42; }
static_assert(noexcept(h(true)), "");
static_assert(!noexcept(h(false)), "");
#include <initializer_list>
#include <iostream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>
template <typename F, typename... Args>
#include <iterator>
#include <type_traits>
template <class Container>
auto to_index(const Container& container, typename Container::const_iterator it)
-> decltype(std::distance(std::begin(container), it))
{
static_assert(std::is_same<
typename std::iterator_traits<
typename Container::const_iterator