回答編集履歴
1
refinement
answer
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
> `std::aligned_storage`を用いる方法とそうでない方法で、どのような違いがあるか
|
2
2
|
|
3
|
-
変換先型`To`に対する「デフォルトコンストラクタの要求」有無が異なると思います。より汎用性の高い実装では、デフォルトコンストラクタを必要としない`std::aligned_storage`が必要となります。
|
3
|
+
変換先型`To`に対する「デフォルトコンストラクタの要求」有無が異なると思います。より汎用性の高い実装では、デフォルトコンストラクタを必要としない `std::aligned_storage` が必要となります。
|
4
4
|
|
5
|
-
cpprefjpの文言は、提案文書 [P0476R2](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0476r2.html) からの引用・翻訳と思われます。
|
5
|
+
cpprefjpの文言は、提案文書 [P0476R2](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0476r2.html) からの引用・翻訳と思われます。原文後半には`aligned_storage`が必要となる理由への言及があります(太字)。
|
6
6
|
|
7
|
-
> Attuned developers use `aligned_storage` with `memcpy`, avoiding alignment pitfalls and allowing them to bit-cast non-default-constructible types.
|
7
|
+
> Attuned developers use `aligned_storage` with `memcpy`, avoiding alignment pitfalls and **allowing them to bit-cast non-default-constructible types**.
|
8
8
|
|
9
9
|
提案者自身による実装例 [jfbastien/bit_cast](https://github.com/jfbastien/bit_cast/blob/master/bit_cast.h) も、下記実装になっています(引用に際して一部簡略化しました):
|
10
10
|
|