Skip to content

Instantly share code, notes, and snippets.

@remyroez
remyroez / file2.txt
Created July 14, 2014 08:45
C++11 と unique_ptr でシングルトン ref: http://qiita.com/remyroez/items/fd35e6af8fbbdbdd73c4
main begin
1: device()
device foo!
2: device foo!
3: device foo!
~device()
4: invalid instance.
5: device()
6: device foo!
7: beacon()
@remyroez
remyroez / file2.txt
Created July 18, 2014 09:25
C++11 の make_shared を拡張する ref: http://qiita.com/remyroez/items/04968f3a2b09f4888f11
0: foo() shared f() ~foo()
1: foo(1234) shared f() ~foo()
2: foo(456) shared custom_deleter f() ~foo()
3: foo(789) shared custom_full f() ~foo()
4: foo() unique f() ~foo()
5: foo(bar) unique f() ~foo()
6: *** error ***
7: foo(42) unique custom_deleter f() ~foo()
@remyroez
remyroez / file0.txt
Last active September 23, 2016 05:04
MSYS2 にてコマンドライン環境をつくる: セットアップ編 ref: http://qiita.com/remyroez/items/757b7b769e9c5a2c4ae7
msys/winpty-git 1~0.2.2.365.79c9859-1
A Windows software package providing an interface similar to a Unix
pty-master for communicating with Windows console programs
@remyroez
remyroez / neural-network-on-matchbox.cpp
Last active October 7, 2016 06:53
マッチ箱の脳 - マッチ箱で作るNN
#include <iostream>
#include <iomanip>
#include <memory>
#include <array>
#include <cmath>
// ニューロン(マッチ箱+お菓子)
class Neuron
{
public:
@remyroez
remyroez / dependency-injection-test.cpp
Created October 14, 2016 02:03
依存性の注入のテスト
#include <iostream>
#include <memory>
class IFoo
{
public:
virtual ~IFoo() {}
virtual int f() = 0;
};
#include <iostream>
#include <string>
#include <locale>
#include <codecvt>
int main()
{
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> converter;
std::string u8str = u8"abcdeあいうえお🗿";
@remyroez
remyroez / utf32-string-stream.cpp
Created November 1, 2016 00:32
UTF32 版 stringstream
#include <iostream>
#include <sstream>
#include <string>
#include <locale>
#include <codecvt>
using w32stringstream = std::basic_stringstream<char32_t>;
int main()
{
@remyroez
remyroez / SFINAE-has-value.cpp
Created November 1, 2016 08:19
SFINAE 特定のメンバ変数を持っているかどうかの trait
#include <iostream>
#include <type_traits>
struct has_value_impl {
template <class T, class U = decltype(T::value)>
constexpr static std::is_same<U, int> test_variable(int);
template <typename...>
constexpr static std::false_type test_variable(...);
@remyroez
remyroez / SFINAE-concept.cpp
Last active November 21, 2016 06:58
SFINAE コンセプト
#include <iostream>
#include <type_traits>
#if (__cplusplus > 201402L)
using std::void_t;
using std::bool_constant;
using std::negation;
using std::conjunction;
using std::conjunction_v;
@remyroez
remyroez / detection-idiom.cpp
Last active November 11, 2016 08:35
Detection Idiom
#include <type_traits>
// impl ----------
#if (__cplusplus > 201402L)
using std::void_t;
#else