Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

非推奨テンプレートstd::auto_ptrを一括置換したい #389

Closed
berryzplus opened this issue Sep 1, 2018 · 2 comments
Closed
Labels
refactoring リファクタリング 【ChangeLog除外】
Milestone

Comments

@berryzplus
Copy link
Contributor

スマートポインタ std::auto_ptr はC++11で非推奨となったテンプレートです。
サクラエディタはC++が規格化される前から存在するものなので、
標準的なC++の作法とズレてるところがちょこちょこあります。

スマートポインタ std::auto_ptr もその1つです。
auto_ptrはダメなのか? - munepi.com
※記事内で言及されている boost::shared_ptr はC++規格に取り込まれて std::shared_ptr になっています。

現状のサクラエディタを MinGW でビルドすると、以下のような警告がたくさん出ます。

[  4%] Building CXX object sakura_core/CMakeFiles/sakura.dir/CGrepAgent.cpp.obj
C:\gitroot\sakura-mygithub\sakura_core\CGrepAgent.cpp: In member function 'void CGrepAgent::AddTail(CEditView*, const CNativeW&, bool)':
C:\gitroot\sakura-mygithub\sakura_core\CGrepAgent.cpp:139:9: warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
    std::auto_ptr<CCodeBase> pcCodeBase( CCodeFactory::CreateCodeBase(
         ^~~~~~~~
In file included from D:/eclipse4.6/eclipse/mingw/lib/gcc/x86_64-w64-mingw32/6.2
.0/include/c++/memory:81:0,
                 from C:\gitroot\sakura-mygithub\sakura_core\StdAfx.h:68,
                 from C:\gitroot\sakura-mygithub\sakura_core\CGrepAgent.cpp:1:
D:/eclipse4.6/eclipse/mingw/lib/gcc/x86_64-w64-mingw32/6.2.0/include/c++/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~

警告の肝は 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations] です。
「gccのオプション -Wdeprecated-declarations を付ければこの警告を無効にできる」と言ってます。
std::auto_ptr の定義ファイル名から、代替が std::unique_ptr であることも分かります。

警告を無効にするのは、対処が必要な警告に気付けない原因となるので避けたいです。

対策として s/std::auto_ptr/std::unique_ptr/g の一括置換を行いたいと思っています。
何かご意見あればここにコメントをお願いします。

@m-tmatma
Copy link
Member

m-tmatma commented Sep 1, 2018

http://fimbul.hateblo.jp/entry/2013/03/20/020349
にも std::auto_ptr の代わりに std::unique_ptr を使え、とありますね。

std::unique_ptr に変えても visual studio 2017 でコンパイル通ります。

@KENCHjp KENCHjp added the refactoring リファクタリング 【ChangeLog除外】 label Sep 2, 2018
@m-tmatma m-tmatma added this to the next release milestone Sep 2, 2018
@m-tmatma
Copy link
Member

m-tmatma commented Sep 2, 2018

#396 で対応済み
のこりは #400 で。

@m-tmatma m-tmatma closed this as completed Sep 2, 2018
@ds14050 ds14050 added the refactoring リファクタリング 【ChangeLog除外】 label Sep 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring リファクタリング 【ChangeLog除外】
Projects
None yet
Development

No branches or pull requests

4 participants