We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
使い所として以下の例が提示されていますが、
if ( auto ptr = std::make_unique<int>(42) ; ptr ) { // 処理 }
これは以下の点が気になります。
if ( auto ptr = std::make_unique<int>(42) ) { // 処理 }
std::make_unique<int>(42)
bool
true
この新しい構文は、宣言される変数と実際に条件分岐に使われる式が異なる場合に力を発揮するので、例えば以下のような感じの例にするのはいかがでしょう。
if ( auto ptr = do_something(); *ptr ) { // 処理 }
The text was updated successfully, but these errors were encountered:
https://qiita.com/yumetodo/items/245e94a0e85db9bf5cbb#comment-804fa063c70a338358cb で私が前にかいた
if(std::size_t pos = s.find_first_of(' '); std::string::npos != pos){ //なんか }
みたいな例のほうがより実用的では
Sorry, something went wrong.
No branches or pull requests
使い所として以下の例が提示されていますが、
これは以下の点が気になります。
std::make_unique<int>(42)
は例外を投げるか、bool
にキャストしてtrue
になるかのどちらかしかない気がします。だとすると、条件分岐の意義がないように思われること。この新しい構文は、宣言される変数と実際に条件分岐に使われる式が異なる場合に力を発揮するので、例えば以下のような感じの例にするのはいかがでしょう。
The text was updated successfully, but these errors were encountered: