プログラミング言語 Go は Google が 2009 年秋にオープンソースで公開した新しいプログラミング言語です。C や C++ のようなコンパイル言語の良さをもちつつ、Python のような動的言語でのプログラムの書き易さを兼ねそなえた特徴をもっています。クラスを使わないオブジェクト指向の言語で、コンカレントに実行するための仕組みもそなえています。 プログラミングをより速く、より生産的に、そしてより楽しくしてくれる新しいプログラミング言語 Go について説明します。
プログラミング言語 Go は Google が 2009 年秋にオープンソースで公開した新しいプログラミング言語です。C や C++ のようなコンパイル言語の良さをもちつつ、Python のような動的言語でのプログラムの書き易さを兼ねそなえた特徴をもっています。クラスを使わないオブジェクト指向の言語で、コンカレントに実行するための仕組みもそなえています。 プログラミングをより速く、より生産的に、そしてより楽しくしてくれる新しいプログラミング言語 Go について説明します。
The Earth is not flat; but it's not round either (Geography on Boost.Geometry)Vissarion Fisikopoulos
What is a great circle, a loxodrome or a geodesic? What are the differences between them and which one is more suitable for each GIS application? This talk addresses this kind of questions and how geography is implemented in Boost.Geometry. The library that is currently being used to provide GIS support to MySQL.
Following up the introductory talk on Boost.Geometry we discuss the algorithmic, the implementation as well as the user perspective of the development of geography in Boost.Geometry. We define basic geometric objects such as geodesics, and the modeling of the Earth as a sphere or ellipsoid. We try to understand the effect of different Earth models to the accuracy and speed of fundamental geometric algorithms (such as length, area, intersection etc.) by showing particular examples. Finally, we are having a look towards the future of geography in Boost.Geometry.
Event : Visual Studio Users Community Japan #1
Date : 2019/09/14
ソフトウェア/サービス開発において最も後回しにされるものの代表が「パフォーマンスの向上」です。C#/.NET の最大の武器は開発生産性ですが、C# 7.0 以降はパフォーマンス向上のための機能追加が多数行われています。いくつかのポイントを押さえることで実装時からより高速なコードを書くことができるようになります。
このドキュメントでは、そんなポイントとなる箇所をふんだんにお届けします。
9. std::auto ptr
特徴
コピーの時に所有権"(=リソース解放の義務)が移譲される
1つのリソースを指す有効なポインタは1個だけ
使えるんならstd::unique ptr を使うべき
使用例:戻り値にする
1 // リソースを生成する関数
2 std :: auto_ptr < ResouceClass > CreateResouce (...){
3 return std :: auto_ptr < ResouceClass >( new ResouceClass (...));
4 }
5
6 // リソースに何かの処理をする
7 void SomeProcess (...){
8 // B u f f e r 1 へ所有権を移譲
9 std :: auto_ptr < ResouceClass > Buffer1 = CreateResouce (...);
10
11 // B u f f e r 2 へ所有権を移譲( 見た目はコピーなのにB u f f e r 1 は無効! )
12 std :: auto_ptr < ResouceClass > Buffer2 = Buffer1 ;
13
14 // いろいろ処理する
15
16 } // <- a u t o _ p t r が自動的に解放してくれる
@NU-Pan 勉強会資料:スマートポインタ入門2014/07/10(木) 9 / 27
10. std::unique ptr
特徴
std::auto ptr と大体同じだがmove" ができる
使えるのはC++11 から(キーワード:右辺値参照、move セマンティクス)
使用例:戻り値にする
1 // リソースを生成する関数
2 std :: unique_ptr < ResouceClass > CreateResouce (...){
3 return std :: unique_ptr < ResouceClass >( new ResouceClass (...));
4 }
5
6 // リソースに何かの処理をする
7 void SomeProcess (...){
8 // B u f f e r 1 へ所有権を移譲( m o v e する)
9 std :: unique_ptr < ResouceClass > Buffer1 = CreateResouce (...);
10
11 // コピー禁止なのでこれはできない-> 無効なB u f f e r 1 は発生しない
12 // std :: unique_ptr < ResouceClass > Buffer2 = Buffer1 ;
13
14 // いろいろ処理する
15
16 } // <- u n i q u e _ p t r が自動的に解放してくれる
@NU-Pan 勉強会資料:スマートポインタ入門2014/07/10(木) 10 / 27
11. boost::scoped ptr
特徴
コピーも移動も出来ない(禁止されている)
あるスコープでのみ有効なポインタとして使える
使用例:例外によるメモリリーク対策
1 class SomeClass {
2 private :
3 ...
4 public :
5 SomeClass (...){
6 boost :: scoped_ptr < ResouceClass > Buffer (new ResouceClass (...));
7
8 // 例外を投げるかも知れない危ない関数を呼ぶ
9 DangerFunction (...); // <- 例外が起きた!
10 }
11 };
12 /*!
13 1 . 例外がt h r o w される
14 2 . コンストラクタを抜けようとする
15 3 . コンストラクタを抜ける時に変数B u f f e r が削除される
16 4 . n e w したR e s o u c e C l a s s のオブジェクトが開放される
17 5 . リソース漏れを起こさずにコンストラクタを抜ける
18 */
@NU-Pan 勉強会資料:スマートポインタ入門2014/07/10(木) 11 / 27
21. すごいぞshared ptr:デリータの指定
デリータとは?
shared ptr によって呼び出される解放関数のこと
デフォルトでははdelete が呼び出される
このデリータはコンストラクタで指定できる
つまりdelete 以外の専用の解放関数が必要なリソースもshared ptr で管理で
きる(すごい!)
IplImage をshared ptr で管理してみる
1 // I p l I m a g e をs h a r e d _ p t r に包んで生成するファクトリ関数
2 boost :: shared_ptr < IplImage > CreateIplImage (int w, int h, int c){
3 IplImage * pImage = cvCreateImage ( cvSize (w, h), IPL_DEPTH_8U , c);
4 return boost :: shared_ptr < IplImage >( pImage , & cvReleaseImage );
5 }
@NU-Pan 勉強会資料:スマートポインタ入門2014/07/10(木) 21 / 27