c++本
スコット・メイヤーズ
Effective C++ 第3版 (ADDISON-WESLEY PROFESSIONAL COMPUTI)
- 作者: スコットメイヤーズ,小林健一郎
- 出版社/メーカー: 丸善出版
- 発売日: 2014/03/18
- メディア: 単行本(ソフトカバー)
- この商品を含むブログ (4件) を見る
新訂版 More Effective C++ (AddisonーWesley professional co)
- 作者: スコット・メイヤーズ,安村通晃,伊賀聡一郎,飯田朱美,永田周一
- 出版社/メーカー: ピアソンエデュケーション
- 発売日: 2007/06/29
- メディア: 単行本(ソフトカバー)
- 購入: 8人 クリック: 129回
- この商品を含むブログ (44件) を見る
Effective Modern C++ ―C++11/14プログラムを進化させる42項目
- 作者: Scott Meyers,千住治郎
- 出版社/メーカー: オライリージャパン
- 発売日: 2015/09/18
- メディア: 大型本
- この商品を含むブログ (7件) を見る
設計
- 作者: エリックガンマ,ラルフジョンソン,リチャードヘルム,ジョンブリシディース,Erich Gamma,Ralph Johnson,Richard Helm,John Vlissides,本位田真一,吉田和樹
- 出版社/メーカー: ソフトバンククリエイティブ
- 発売日: 1999/10
- メディア: 単行本
- 購入: 21人 クリック: 711回
- この商品を含むブログ (210件) を見る
- 作者: マーティン・レディ,Martin Reddy,三宅陽一郎,ホジソンますみ
- 出版社/メーカー: SBクリエイティブ
- 発売日: 2012/10/31
- メディア: 単行本
- 購入: 4人 クリック: 106回
- この商品を含むブログ (11件) を見る
古め
- 作者: ジョン・ラコス,滝沢徹,牧野祐子
- 出版社/メーカー: ピアソンエデュケーション
- 発売日: 2007/12/14
- メディア: 単行本(ソフトカバー)
- 購入: 5人 クリック: 70回
- この商品を含むブログ (15件) を見る
テンプレート
- 作者: επιστημη,高橋晶
- 出版社/メーカー: SBクリエイティブ
- 発売日: 2014/04/16
- メディア: 単行本
- この商品を含むブログ (6件) を見る
古め
Modern C++ Design―ジェネリック・プログラミングおよびデザイン・パターンを利用するための究極のテンプレート活用術 (C++ In‐Depth Series)
- 作者: アンドレイアレキサンドレスク,Andrei Alexandrescu,村上雅章
- 出版社/メーカー: ピアソンエデュケーション
- 発売日: 2001/12
- メディア: 単行本
- 購入: 12人 クリック: 214回
- この商品を含むブログ (102件) を見る
最適化
Optimized C++ ―最適化、高速化のためのプログラミングテクニック
- 作者: Kurt Guntheroth,島敏博,黒川利明
- 出版社/メーカー: オライリージャパン
- 発売日: 2017/02/22
- メディア: 単行本(ソフトカバー)
- この商品を含むブログ (2件) を見る
古め
Efficient C++パフォーマンスプログラミングテクニック
- 作者: ダブブルカ,デビットメイヒュ,浜田光之,Dov Bulka,David Mayhew,浜田真理
- 出版社/メーカー: ピアソンエデュケーション
- 発売日: 2000/07
- メディア: 単行本
- 購入: 9人 クリック: 149回
- この商品を含むブログ (31件) を見る
最新仕様
- 作者: 江添亮
- 出版社/メーカー: KADOKAWA
- 発売日: 2018/03/09
- メディア: 単行本
- この商品を含むブログを見る
[改訂第3版]C++ポケットリファレンス (POCKET REFERENCE)
- 作者: 高橋晶,安藤敏彦,一戸優介,楠田真矢,湯朝剛介
- 出版社/メーカー: 技術評論社
- 発売日: 2018/02/15
- メディア: 単行本(ソフトカバー)
- この商品を含むブログを見る
標準入力をsplitして、行と列を変換するpythonスクリプト
例えば、以下のような9行を3行ずつsplitして、
このように整形したいとき、bashで一度にうまくやる方法がわからなかったので自作。
split-transpose.py
#!/usr/bin/env python import sys def split_transpose(n): line = '' count = 0 for l in iter(sys.stdin.readline, ''): line += l.rstrip() + '\t' count += 1 if count == n: print(line) line = '' count = 0 if count != 0: print(line) if __name__ == '__main__': if len(sys.argv) > 1: split_transpose(int(sys.argv[1]))
デリミタはとりあえずtab固定。
seq 12 を4行ごとにsplit-transposeした結果
$ seq 12 | ./split-transpose.py 4 1 2 3 4 5 6 7 8 9 10 11 12
標準入力をsplitしてpasteするpythonスクリプト
標準入力を指定行数でsplitして、その結果をpaste、 というのを一度にやりたかったけど良い方法がわからなかったのでpythonで自作した。
例えば以下のような9行を3行でsplitして、
このようにpasteする。
#!/usr/bin/env python import sys def split_paste(n): d = [[] for _ in range(n)] for i, l in enumerate(iter(sys.stdin.readline, '')): d[i % n].append(l.rstrip()) for l in d: print('\t'.join(l)) if __name__ == '__main__': if len(sys.argv) > 1: split_paste(int(sys.argv[1]))
デリミタはとりあえずtab固定。
seq 12 を4行ごとにsplit-pasteした結果
$ seq 12 | ./split-paste.py 4 1 5 9 2 6 10 3 7 11 4 8 12
カーネルモジュールのサンプル
LinuxのCharacter deviceのひな形。最近はprintkではなく、pr_xxxを使うらしい。
まずMakefile。
KDIR = /lib/modules/$(shell uname -r)/build obj-m += sample.o all: make -C $(KDIR) M=$(PWD) clean: make -C $(KDIR) M=$(PWD) clean
Character deviceを作るsample.c。
#include <linux/module.h> #include <linux/kernel.h> #include <linux/cdev.h> #include <linux/device.h> #include <linux/fs.h> #include <linux/slab.h> #define DEV_NAME "sample" struct sample_dev_t { dev_t id; struct cdev cdev; struct class *class; struct device *dev; } *sample_dev; static int sample_open(struct inode *inode, struct file *filp) { pr_info("open\n"); return 0; } static int sample_close(struct inode *inode, struct file * filp) { pr_info("close\n"); return 0; } static ssize_t sample_read(struct file *filp, char __user *buf, size_t size, loff_t *offset) { pr_info("read\n"); return 0; } static ssize_t sample_write(struct file *filp, const char __user *buf, size_t size, loff_t *offset) { pr_info("write\n"); return 0; } static long sample_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { pr_info("ioctl cmd %d arg %ld\n", cmd, arg); return 0; } struct file_operations sample_fops = { .owner = THIS_MODULE, .open = sample_open, .release = sample_close, .read = sample_read, .write = sample_write, .unlocked_ioctl = sample_ioctl, }; static int __init sample_init(void) { int err; pr_info("%s:init\n", DEV_NAME); sample_dev = kmalloc(sizeof(struct sample_dev_t), GFP_KERNEL); if (!sample_dev) { pr_err("kmalloc err\n"); return -ENOMEM; } err = alloc_chrdev_region(&sample_dev->id, 0, 1, DEV_NAME); if (err) { pr_err("alloc_chrdev_region err %d\n", err); goto out_free; } cdev_init(&sample_dev->cdev, &sample_fops); sample_dev->cdev.owner = THIS_MODULE; err = cdev_add(&sample_dev->cdev, sample_dev->id, 1); if (err) { pr_err("cdev_add err %d\n", err); goto out_unregister; } sample_dev->class = class_create(THIS_MODULE, DEV_NAME); if (IS_ERR(sample_dev->class)) { err = PTR_ERR(sample_dev->class); pr_err("class_create err %d\n", err); goto out_cdev_del; } sample_dev->dev = device_create(sample_dev->class, NULL, sample_dev->id, NULL, DEV_NAME); if (IS_ERR(sample_dev->dev)) { err = PTR_ERR(sample_dev->dev); pr_err("device_create err %d\n", err); goto out_class_destroy; } return 0; out_class_destroy: class_destroy(sample_dev->class); out_cdev_del: cdev_del(&sample_dev->cdev); out_unregister: unregister_chrdev_region(sample_dev->id, 1); out_free: kfree(sample_dev); return err; } static void __exit sample_exit(void) { pr_info("exit\n"); device_destroy(sample_dev->class, sample_dev->id); class_destroy(sample_dev->class); cdev_del(&sample_dev->cdev); unregister_chrdev_region(sample_dev->id, 1); kfree(sample_dev); } module_init(sample_init); module_exit(sample_exit); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("kernel module sample");
試しに /dev/sample をcatする。
sudo insmod ./sample.ko sudo cat /dev/sample
syslogに以下のログが出る。
Mar 24 22:31:18 0805LM kernel: [12515.692818] sample:init Mar 24 22:31:30 0805LM kernel: [12527.303679] open Mar 24 22:31:30 0805LM kernel: [12527.303690] read Mar 24 22:31:30 0805LM kernel: [12527.303692] close