Sprout を使った簡単な constexpr counting_iterator
Sprout の index_iterator で簡単に実装出来そうだったのでちょっと試してみた。
[ソース]
#define SPROUT_CONFIG_SUPPORT_TEMPORARY_CONTAINER_ITERATION #include <sprout/algorithm/transform.hpp> #include <sprout/iterator/index_iterator.hpp> #include <sprout/array.hpp> #include <sprout/pit.hpp> #include <iostream> template<typename IndexType> struct dummy : sprout::array<IndexType, 1>{ typedef IndexType reference; typedef IndexType size_type; constexpr IndexType at(IndexType i) const{ return i; } constexpr IndexType operator[](IndexType i) const{ return i; } }; template<typename IndexType> constexpr sprout::index_iterator<dummy<IndexType>> counting_iterator(IndexType index){ return { dummy<IndexType>{}, index }; } constexpr int twice(int n){ return n + n; } int main(){ static constexpr auto result = sprout::transform( counting_iterator(-5), counting_iterator(5), sprout::pit<sprout::array<int, 10>>(), twice ); for(auto&& n : result){ std::cout << n << std::endl; } return 0; }
[出力]
-10 -8 -6 -4 -2 0 2 4 6 8
とりあえず、簡単に書いてみた。
型を定義するのが手間だったので、sprout:array を継承してごまかしている。
unite-checking-global-variables
名前が無駄に長いんですが、0 と 1 のグローバル変数を unite.vim で編集する unite-source です。
要はチェックボックスですね。
元々は unite.vim でチェックボックスを記述する為のテストソースとして書いていたんですが、そのままでも使えそうだったのでプラグインにしてみました。
(既にその手のプラグインはありそうですが。
[既存の問題]
アクションメニュー(a) から action を選ぶと画面が更新されません。
(この場合に更新するタイミングが分からなかったのよね…。
修正しました。
あとソートを行う関係で [x] で絞り込みも出来ません。