lab.comp@wiki内検索 / 「C++/Tips /Technique」で検索した結果

検索 :
  • C++/Technique
    compile-time-polymorphism (コンパイル時多態) C++でプロパティ コンパイラが自動生成する関数を使用禁止にする
  • C++/Tips
    環境に非依存なTips 環境依存Tips STL リンク 環境に非依存なTips 円周率π(pi)の定義の仕方 2次元配列へのラスタ捜査 関数に配列をリファレンスで渡す 実行時間を計測する 直交座標から角度を求める 環境依存Tips ただし、今のところはVisual Studio 2005の環境のみ。 特定の警告 (warning) を抑制する リンクするライブラリをコードに埋め込む Visual Studio 2005のIntelliSenseに関するTips STL STL (Standard Template Library)とは STLでファイルコピー 内積を求める 関数オブジェクト雛型 コマンドライン引数(配列)をダンプ リンク シリアルポート (COM、RS232C) のオープンとクローズ トップメニューから...
  • C++/Tips/Technique/CppProperty
    http //www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1615.pdfから参照 Code? Code?
  • C++/Tips/Technique/CompileTimePolymorphism
    東方算程譚 - アヒルの判別から参照。 Code #include iostream  struct point_tag {};struct vector_tag {}; struct Point { typedef point_tag type;}; struct Vector { typedef vector_tag type;}; // Point用 printvoid print_(const Point target, point_tag) { std cout "Point\n";} // Vector用 printvoid print_(co...
  • C++/Tips/Technique/CompileTimePolymorphism/Code
    #include iostream  struct point_tag {};struct vector_tag {}; struct Point { typedef point_tag type;}; struct Vector { typedef vector_tag type;}; // Point用 printvoid print_(const Point target, point_tag) { std cout "Point\n";} // Vector用 printvoid print_(const Vector target, vector_tag&#...
  • C++/Tips/Technique/コンパイラが自動生成する関数を使用禁止にする
    気が向いたら解説します。 Code class foo {private foo(); // デフォルトコンストラクタを使用禁止 foo(const foo ); // コピーコンストラクタを使用禁止 foo operator= (const foo ); // 代入演算子を使用禁止}; 
  • C++/Tips /Technique/コンパイラが自動生成する関数を使用禁止にする/Code
    class foo {private foo(); // デフォルトコンストラクタを使用禁止 foo(const foo ); // コピーコンストラクタを使用禁止 foo operator= (const foo ); // 代入演算子を使用禁止}; 
  • C++/Tips/STL
    STL (Standard Template Library)とは STLでファイルコピー 内積を求める 関数オブジェクト雛型 コマンドライン引数(配列)をダンプ
  • ネイティブ (unmanaged) 関数のラップ
    ネイティブ (unmanaged) な関数を、C++/CLI (managed) でラップして使う。 環境はVisual Studio 2005。 プロジェクトの参照設定や、インクルードディレクトリの設定など、適切に行うこと。 設定がわからない人は下部にあるリンクを参考にしてください。 ネイティブ (unmanaged) 関数hello.hpp hello.cpp C++/CLI (managed) によるラッパクラスhellolib.hpp hellolib.cpp managedな言語 (C#) からの呼び出しProgram.cs 参考リンク アーカイブ ネイティブ (unmanaged) 関数 hello.hpp #pragma once #include string void hello(); void show( int i ); void show...
  • C++/画像処理入門/Contents
    はじめに 想定する言語及び画像処理ライブラリ 対象者 1. 画像処理の基礎の基礎 2. 2値画像処理? 3. 画像のフィルタリング? はじめに 思いつきで初めてみました。 飽きたら突然終了します。 面倒くさがりなので、基本的には、原理の解説は可能な限り解説ページのリンクを貼る方針でいきます。 想定する言語及び画像処理ライブラリ 言語はC++、画像処理ライブラリにはBoost.GILを想定しています。 Boost.GILはテンプレートを多用しているため、多少プログラミングの経験がないと少し難解かもしれません。 対象者 C++の文法が理解できる C++でSTLの使用経験がある 画像処理関連の研究・開発に従事している、入門者 Boost.GILの使い方が知りたい人 ※ STL (Standard Template Library) については、下記を参照 ...
  • C++/Tips/直交座標から角度を求める
    直交座標 (x, y)から角度θを求める。 arctan( y / x ) の式で求めることができるが、ヘッダ cmath に含まれる関数tan()の戻り値は[-π/2 ~ +π/2]となっており、 180度周期であるため、360度周期の角度を求めることができない。 そのため、atan2()を使用する。 cmath ヘッダをインクルードし、 atan2( y, x ); のように使う。戻り値は[-π ~ +π]である。 ラジアンから度数法に直すときは、 double angle = atan2( y, x ) * 180/PI; とすることで、[0 ~ 360]の値が得られる。 int angle = static_cast int ( atan2( y, x ) * 180/PI + 360 ) % 360; とすれば、[0 ~ 359]...
  • C++とC++/CLIの型対応表
    C++型 C++/CLI型 bool System.Boolean signed char System.SByte unsigned char System.Byte wchar_t System.Char double, long double System.Double float System.Single int, signed int, long, signed long System.Int32 unsigned int, unsigned long System.UInt32 __int64, signed__int64 System.Int64 unsigned__int64 System.UInt64 short, signed short System Int16 unsig...
  • メモ2
    {{{ # Doxyfile for Doxygen 1.7.4 ################################################################################ # Project ################################################################################ DOXYFILE_ENCODING = UTF-8 # このタグでは、設定ファイルのすべての文字に使うエンコードを指定します。 # デフォルトはUTF-8で、このタグが最初に指定される前のすべてのテキストもUTF-8です。 # Doxygenはlibiconv(libcにビルトインされているiconv)を使って変換しています。 # エンコードの種類につい...
  • Java/Tips
    Java Tipsです。
  • Cpp/Qt
    はじめに C++でGUIプログラミングを行います。 ただし、C++の標準ライブラリにはGUIのためのライブラリがありません。 C++でGUIプログラミングをするためのライブラリは色々ありますが、ここではQtというライブラリを使用します。 参考リンク:Qt (Wikipedia) 対象者 C++の文法が理解できる コンテンツ +開発環境のインストール 開発環境のインストール 下記のサイトからLGPl/Free版のQt SDK最新版をダウンロードしてインストールする。 http //qt.nokia.com/downloads-jp ※ 本稿執筆時の最新版はQt SDK 2009.04 (qt-sdk-win-opensource-2009.04.exe) ですが、なぜかQt Creatorが日本語化されていません。 日本語で使いたい場合は、下記サイトか...
  • DesignPattern/Singleton
    singleton パターンです。 気が向けばそのうち解説文を書きます。 C++ #include iostream  class singleton {private static singleton* p_instance_; // 唯一のインスタンス static bool destroyed_; // インスタンスの廃棄フラグ public static singleton instance() { if (!p_instance_) { if (destroyed_) { // 既にインスタンスが廃棄されていたらエラー on_...
  • その他/VirtualBoxをWindowsサービス化_win7
    VirtualBoxをWindowsサービス化する (Windows 7) VirtualBoxをWindowsサービス化する (Windows 7)はじめに 起動・停止のスクリプト化起動スクリプト 停止スクリプト WinSWの設定ファイル サービス化 VirtualBoxで作成した仮想マシンをWindowsのサービスとして動作させてみた。 環境 OS Windows 7 x64 PowerShell PowerShell V3 VirtualBox VirtualBox 4.3.26 使用したソフト WinSW WinSW 1.16 はじめに VirtualBoxをWindowsサービスとして動作させたかった。 Windowsサービスとして動作させたい要件は下記の通り。 要件 ホストOSの起動時に仮想マシンも起動すること ホストOSの停止...
  • 2次元配列へのラスタ捜査
    #include iostream #include vector #include algorithm #include boost/timer.hpp #include boost/numeric/ublas/matrix.hpp  int main(){ namespace ublas = boost numeric ublas; const int M = 10000, N = 20000;  // boost ublas使用版 { ublas matrix int a( M, N );  boost timer t; std fill( a.data().begin(),...
  • GIL (Generic Image Library)
    Generic Image Library (GIL) Adobeが提供しているオープンソースの画像処理ライブラリ。 Boost C++ Librariesに加えられました。 Adobe 公式サイト http //opensource.adobe.com/gil/index.html Boost ドキュメント http //www.boost.org/doc/libs 稲葉一浩氏による解説 (Let s Boost) http //www.kmonos.net/alang/boost/classes/gil.html 公式サイトのTutorial、DesignGuideの非公式日本語訳 http //sites.google.com/site/twinkleofsilence/ 覚え書き 画像の読み込み、保存 座標演算 (point2) 色空間の変換...
  • 各種テンプレート
    Windows バッチスクリプト PowerShell スクリプト Windows バッチスクリプト +code @echo off ***************************************************************************** * @file * @author leo * @version 1.0.0 * @brief {ファイルの概要} * @details {ファイルの詳細説明} ***************************************************************************** *******************************************************...
  • DesignPattern/IteratorPattern
    Iteratorパターンの例です。 気が向けばそのうち解説文を書きます。 一般的なIteratorパターンの実装例Java C++ 一般的なIteratorパターンの実装例 Java package sample.design_pattern; interface Iterator { public abstract boolean hasNext(); public abstract void next();  public abstract Object getValue();}   interface Aggregate { public abstract Iterator iterator();&#...
  • メモ
    MoinMoinをWindowsでインストールする(覚え書き) Pythonをインストールし、pathを設定 (ex. c \python) Apacheをインストール mod_wsgiのWindowsバイナリをダウンロードし、Apacheインストールディレクトリのmodulesにコピー コピーしたファイルをmod_wsgi.soにリネーム httpd.confに下記を追記 LoadModule wsgi_module modules/mod_wsgi.so 最近、愛用の辞書「英辞郎 on the WEB」の検索用URLが変わってしまって、 Firefox拡張「Dictionary Tooltip」で検索ができなくて困っていました。 そこで、英辞郎のURLの変更方法 dictionarytip_dictScript.js の、578行目あたりにある ...
  • DesignPattern
    デザインパターンにおける、JavaとC++の実装例を置いておきます。 解説はそのうち気が向いたらつけます。 Iterator パターン Singleton パターン
  • OpenCVのインストール
    Visual Studio 2005でのインストール手順について。 http //sourceforge.net/projects/opencvlibrary/ からWin用のバイナリをダウンロードしてインストール。 OpenCVで作成した実行ファイル(*.exe)を実行するには、OpenCVのライブラリ (*.dll) にパスを通す必要がある。インストール先がデフォルトの場合、 C \Program Files\OpenCV\bin にあるため、パスを通しておく(システムのプロパティから環境変数を設定する)。 それとは別に、コンパイラにヘッダとライブラリの位置を教えてやる。 「ツール」→「オプション」→「プロジェクトおよびソリューション」→「VC++ディレクトリ」を選択する。「ディレクトリを表示するプロジェクト」で、以下の項目を設定する。 「インクルー...
  • 実行時間を計測する
    ctimeヘッダ(time.h)をインクルードして行う。 いくつか方法がある。 一般的に、clock()よりもOS固有のAPIを使ったほうが精度は高い。 環境非依存 clock()を使用する方法 POSIX (Unix, Linux) gettimeofday()を使用する方法 Windows QueryPerformanceCounter()を使用する方法 詳細は省略。 Googleで検索して。
  • DesignPattern/IteratorPattern/JavaCode1
    package sample.design_pattern; interface Iterator { public abstract boolean hasNext(); public abstract void next();  public abstract Object getValue();}   interface Aggregate { public abstract Iterator iterator();}   class Element { private int value;  public Element(int valu...
  • DesignPattern/Singleton/cpp_code1
    #include iostream  class singleton {private static singleton* p_instance_; // 唯一のインスタンス static bool destroyed_; // インスタンスの廃棄フラグ public static singleton instance() { if (!p_instance_) { if (destroyed_) { // 既にインスタンスが廃棄されていたらエラー on_dead_reference(); } else ...
  • DesignPattern/IteratorPattern/CppCode1
    #include iostream using namespace std; template typename T struct iteratable { virtual ~iteratable() {}  virtual const bool has_next() = 0; virtual void next() = 0; virtual const T get_value() = 0;}; template typename Iterator struct aggregatable { virtual ~aggregatable() {} virtual Itera...
  • Visual Studio 2005のIntelliSenseに関するTips
    // 下の書き方ではIntelliSenseが働かないnamespace xx = Name space;// IntelliSenseを使いたいときはこう書くnamespace xx { using namespace Name space; } 
  • Onlinesoft
    ファイル関連 インターネット・ネットワーク関連 マルチメディア関連 ユーティリティ関連 システム関連 ファイル関連 圧縮・解凍 Lhaz ポップアップでできる圧縮・解凍ソフト。もちろん、ダブルクリックで解凍とかも可能。解凍せずに書庫閲覧できる機能がステキ。 エディタ サクラエディタ 軽くて多機能なエディタ。SDIでタブなインタフェース。 Mery シンプルかと思いきや、多機能なテキストエディタ。 Visual Studio Code Microsoft 製の Electron 系エディタ。 ファイラ X-Finder 多機能ファイラ。 CubicExplorer Portable シンプルなタブ型ファイラ オフィスソフト Open Office オープンソースのオフィスソフト。ファッキンWindows...
  • C++/Guidelines/変更を可能にしたい場合のみconstを外す/Code
    const char * const massage = "hello."; void print(const Foo * const foo) {} void print(const Foo foo) {} const std vector int const_iterator it = vec.begin(); class int_array {public // ... const std size_t size() const { return data_.size(); }  // constなオブジェクトのた...
  • C++ - Links
    画像処理ライブラリ 画像圧縮・展開ライブラリ 画像処理ライブラリ Adobe GIL (Generic Image Library) http //opensource.adobe.com/gil/ Boostに採択されたらしい。 Vigra http //kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ 結構メジャーっぽい。 OpenCV http //sourceforge.net/projects/opencvlibrary/ Intel製のコンピュータビジョンライブラリ。 CxImage http //www.codeproject.com/bitmap/cximage.asp FreeImage http //freeimage.sourceforge.net/ ImageMagic http //...
  • C++/Guidelines/変更を可能にしたい場合のみconstを外す
    constをデフォルトで使用し、変更を可能にしたい場合のみconstを外す。 Code const char * const massage = "hello."; void print(const Foo * const foo) {} void print(const Foo foo) {} const std vector int const_iterator it = vec.begin(); class int_array {public // ... const std size_t size() const { return data_.s...
  • 関数に配列をリファレンスで渡す
    #include iostream using namespace std; #define N 5 void func( int ( a )[N][N] ) { a[0][0] = 10;} int main(){ int a[N][N];  for( int i=0; i N; ++i ) { for( int j=0; j N; ++j ) { a[i][j] = i + j; } }&...
  • C++/Guidelines/定数はconst宣言する/Code
    // 良くない例#define PI 3.14 // 良い例const double pi = 3.14;const char * const name = "hoge";const std string language("cpp"); class hoge { static const int num = 3;}; class foo { enum { num = 3 };}; class bar { static const double rate;};const double foo rate = 2.1; 
  • C++/Guidelines/定数はconst宣言する
    const 宣言の例 Code // 良くない例#define PI 3.14 // 良い例const double pi = 3.14;const char * const name = "hoge";const std string language("cpp"); class hoge { static const int num = 3;}; class foo { enum { num = 3 };}; class bar { static const double rate;};const double foo rate = 2.1; 
  • Cpp/Qt/HelloWorld/Code01
    #include QApplication #include QLabel  int main(int argc, char **argv) { QApplication app(argc, argv); // アプリケーションのリソース管理をするクラス QLabel *label = new QLabel("Hello world."); // Widget (ラベル)  label- show(); // Widgetを表示  return app.exec(); ...
  • Cpp/Qt/HelloWorld
    解説文はそのうち書きます。 #include QApplication #include QLabel  int main(int argc, char **argv) { QApplication app(argc, argv); // アプリケーションのリソース管理をするクラス QLabel *label = new QLabel("Hello world."); // Widget (ラベル)  label- show(); // Widgetを表示  ...
  • Windows Tips
    Windows XP回復コンソールをインストールする PCの時刻同期間隔を調整する Windowsに自動ログオンする 検索画面をWindows 2000と同じにする Windows 10 でランチャに登録しておくと便利なコマンド環境変数を編集 資格情報マネージャー 参考URLコマンド アイコン Windows XP 回復コンソールをインストールする ファイル名を指定して実行から、 x \i386\winnt32 /cmdcons を実行(xはドライブ名)。 コマンド 内容 sttrib ファイル属性(読み取り専用、システム、隠し)変更 cd カレントフォルダの変更 copy ファイルのコピー del ファイルの削除 ren ファイル名の変更 md フォルダの作成 rd フォルダの削除 type テ...
  • C++/Guidelines/余計なコメントを付けない
    コメントを付けることは、よいことである。 しかし、適切でないコメントは、有害でしかない。 例えば、次のようなコードがあったとする。 // 配列aの0~nに0を代入 for (int i = 1; i = N; ++i) { a[i] = 0; // 配列aのi番目の要素に0を代入 } 上記のようなコメントは、何をしたいのか一目で分からないばかりでなく、内容が間違っている。 コメントは厄介なものである。 コンパイラは命令文の文法的な誤りは指摘してくれても、コメントの誤りに関しては何ら教えてはくれない。 コードを修正する場合は、必ず、コメントも修正するように意識すべきだ。 また、「処理の説明」をしているコメントは、命令文との重複であり、ソースコードの無駄づかいにすぎない。 ソースコードの行数が増えるほど、反比例して理解しやすさが損なわれること...
  • C++/画像処理入門/1.画像処理の基礎の基礎/画像の種類と構造
    画像の種類ベクタ画像 (Vector Image) とは ラスタ (Laster Image) 画像とは 画像の構造色空間 (Color Space)RGB グレースケール (Gray Scale) その他の色空間 ビット深度 (Bit Deapth) 画像の種類 ※ 画像処理入門者は、「画像の種類」は読み飛ばして構いません。あんまり最初から小難しい話をするとイヤになるので。 コンピュータ上で扱う画像の形式には、ベクタ画像とラスタ画像の2種類がありますが、このサイトで扱う画像処理は、全てラスタ画像を対象としてます。 これ以降、単に「画像」と言った場合にはこのラスタ画像を指すものとします。 ベクタ画像 (Vector Image) とは 直線や曲線といった幾何情報をデータとして保持している形式です。 そのため、コンピュータ上で描かれたグラフィクスを保存するには向いていま...
  • 内積を求める
    #include iostream #include vector #include numeric using namespace std; int main(){ vector int v1( 5 ), v2( 5 );  for( int i=0; i v1.size(); ++i ) { v1[i] = i; v2[i] = i + 1; }  int x = inner_product( v1.begin(), v1.end(), v2.begin(), 0 );  c...
  • trac/Install
    稼働環境 インストール 起動 稼働環境 Windows7 Ultimate SP1 x64 Internet Explorer 9 TracLightning 3.1.3 インストール すべてデフォルト設定のままインストール 起動 [スタートメニュー]-[すべてのプログラム]-[Trac]-[コマンドプロンプトから実行] 参考ページ
  • GIL - 座標演算 (point2)
    2次元座標の演算 ソース #include iostream #include string #include boost/format.hpp #include boost/gil/utilities.hpp using namespace std; using namespace boost; using namespace boost gil; string show( string expression, point2 int p ) { return str( format( "%s = (%3d, %3d)" ) % expression % p.x % p[1] ); } int main() { point2 int p1( 10, 100 ); point2 int p2; p2.x ...
  • STL - 関数オブジェクト雛型
    #include functional using namespace std;   // 単項関数オブジェクトの雛型 template typename Argument, typename Result struct class_name public unary_function Argument, Result { Result operator () ( Argument arg ) { // ...; } };   // 2項関数オブジェクトの雛型 template typename Argument1, typename Argument2, typename Result struct class_name public binar...
  • @wiki全体から「C++/Tips /Technique」で調べる

更新順にページ一覧表示 | 作成順にページ一覧表示 | ページ名順にページ一覧表示 | wiki内検索