C++

boolから整数型に変換する時、falseは0に、trueは1になる

N1905 [conv.integral] If the destination type is bool, see 4.12. If the source type is bool, the value false is converted to zero and the value true is converted to one. [conv.bool] An rvalue of arithmetic, enumeration, pointer, or pointer…

std::setの要素を追加・削除しても既存の要素への参照やイテレータは有効なまま維持される

N1905 23.1.2 - 8 The insert members shall not affect the validity of iterators and references to the container, and the erase members shall invalidate only iterators and references to the erased elements C++の連想コンテナ全般(setとかmap系…

C++11以降で #define private public を弾く

C++

# define private public 検出器です.ついでに # define static_assert(...) 検出器も付けました.ご査収ください. http://t.co/l7oyLoZ9ky— でちまるさん(実際かわいい) (@decimalbloat) 2015, 6月 10 [Wandbox]三へ( へ՞ਊ ՞)へ ハッハッ https://t.co/k2oQ…

*nix環境でC++コードを書き殴るのに最高に便利なツールを作った

C++

C++ ファイルのコンパイル & 実行を LL系言語並に快速にするツールを開発しました https://t.co/vFG6YPXF0Y— にゃおきゃっと (@nyaocat) 2015, 8月 5 ファイル中にコンパイルフラグを含められるのと、そのままファイルを実行する形式でガンガン書けるので我…

gtkmm と SDL2 を組み合わせて使う

能書き Gtk+ には特殊なウィジェットとして socket, plug ウィジェットがあり, 親プロセスの持つ socket ウィジェット内に 別プロセスから plug ウィジェットを用いて描画させることが出来る. これだけでも充分面白いが,socket ウィジェットはウィジェッ…

declval<T>() の返り値型が T&& である理由

メモ。 そもそも declval とは? 型T1, T2 があり、それらの値を乗算した結果の型を得たい場合、 素直に考えると decltype( T1() * T2() ) で得られそうだが、これは T1, T2 共にデフォルトコンストラクタが無いと T1(),T2()がコンパイルエラーになってしま…

C++11のささやかなネタコード

C++

C++11 では initializer_list が実装されたのでこんなことができます data.txt { { {1, 3}, {5, 8} }, { {3, 8}, {1, 0}, {8, 8} } } main.cpp #include <iostream> #include <utility> #include <vector> using namespace std; vector<vector<pair<int, int>>> dataset #include "data.txt" ; int main(){} 展</vector<pair<int,></vector></utility></iostream>…