Mercurial > hg > CbC > CbC_gcc
comparison libstdc++-v3/include/ext/aligned_buffer.h @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 84e7813d76e9 |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 // Aligned memory buffer -*- C++ -*- | 1 // Aligned memory buffer -*- C++ -*- |
2 | 2 |
3 // Copyright (C) 2013-2018 Free Software Foundation, Inc. | 3 // Copyright (C) 2013-2020 Free Software Foundation, Inc. |
4 // | 4 // |
5 // This file is part of the GNU ISO C++ Library. This library is free | 5 // This file is part of the GNU ISO C++ Library. This library is free |
6 // software; you can redistribute it and/or modify it under the | 6 // software; you can redistribute it and/or modify it under the |
7 // terms of the GNU General Public License as published by the | 7 // terms of the GNU General Public License as published by the |
8 // Free Software Foundation; either version 3, or (at your option) | 8 // Free Software Foundation; either version 3, or (at your option) |
47 struct __aligned_membuf | 47 struct __aligned_membuf |
48 { | 48 { |
49 // Target macro ADJUST_FIELD_ALIGN can produce different alignment for | 49 // Target macro ADJUST_FIELD_ALIGN can produce different alignment for |
50 // types when used as class members. __aligned_membuf is intended | 50 // types when used as class members. __aligned_membuf is intended |
51 // for use as a class member, so align the buffer as for a class member. | 51 // for use as a class member, so align the buffer as for a class member. |
52 // Since GCC 8 we could just use alignof(_Tp) instead, but older | |
53 // versions of non-GNU compilers might still need this trick. | |
52 struct _Tp2 { _Tp _M_t; }; | 54 struct _Tp2 { _Tp _M_t; }; |
53 | 55 |
54 alignas(__alignof__(_Tp2::_M_t)) unsigned char _M_storage[sizeof(_Tp)]; | 56 alignas(__alignof__(_Tp2::_M_t)) unsigned char _M_storage[sizeof(_Tp)]; |
55 | 57 |
56 __aligned_membuf() = default; | 58 __aligned_membuf() = default; |
84 // and <bits/hashtable_policy.h>, but ideally they would use __aligned_membuf | 86 // and <bits/hashtable_policy.h>, but ideally they would use __aligned_membuf |
85 // instead, as it has smaller size for some types on some targets. | 87 // instead, as it has smaller size for some types on some targets. |
86 // This type is still used to avoid an ABI change. | 88 // This type is still used to avoid an ABI change. |
87 template<typename _Tp> | 89 template<typename _Tp> |
88 struct __aligned_buffer | 90 struct __aligned_buffer |
89 : std::aligned_storage<sizeof(_Tp), std::alignment_of<_Tp>::value> | 91 : std::aligned_storage<sizeof(_Tp), __alignof__(_Tp)> |
90 { | 92 { |
91 typename | 93 typename |
92 std::aligned_storage<sizeof(_Tp), std::alignment_of<_Tp>::value>::type | 94 std::aligned_storage<sizeof(_Tp), __alignof__(_Tp)>::type _M_storage; |
93 _M_storage; | |
94 | 95 |
95 __aligned_buffer() = default; | 96 __aligned_buffer() = default; |
96 | 97 |
97 // Can be used to avoid value-initialization | 98 // Can be used to avoid value-initialization |
98 __aligned_buffer(std::nullptr_t) { } | 99 __aligned_buffer(std::nullptr_t) { } |