Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Changes
Page history
Update cpp
authored
Oct 18, 2023
by
umaumax
Hide whitespace changes
Inline
Side-by-side
cpp.md
View page @
3633728d
...
...
@@ -841,6 +841,20 @@ UNIx STanDard Header file
*
[
C言語 未初期化変数の罠 \- 気まま研究所ブログ
](
https://aonasuzutsuki.hatenablog.jp/entry/2018/12/21/111450
)
*
[
変数の初期化をサボるな,それから \-Wshadow オプションを使え \- akihiko’s tech note
](
https://aki-yam.hatenablog.com/entry/20130718/1374163303
)
### 複雑な処理をした結果のconst初期化
[
C++ Core Guidelines
](
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es28-use-lambdas-for-complex-initialization-especially-of-const-variables
)
e.g.
```
cpp
const
widget
x
=
[
&
]
{
widget
val
;
// assume that widget has a default constructor
for
(
auto
i
=
2
;
i
<=
N
;
++
i
)
{
// this could be some
val
+=
some_obj
.
do_something_with
(
i
);
// arbitrarily long code
}
// needed to initialize x
return
val
;
}();
```
### 配列の初期化
```
cpp
#include
<array>
...
...
...
...