File indexing completed on 2025-01-18 09:43:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef BOOST_OPTIONAL_OPTIONAL_DETAIL_OPTIONAL_ALIGNED_STORAGE_AJK_12FEB2016_HPP
0015 #define BOOST_OPTIONAL_OPTIONAL_DETAIL_OPTIONAL_ALIGNED_STORAGE_AJK_12FEB2016_HPP
0016
0017 namespace boost {
0018
0019 namespace optional_detail {
0020
0021
0022
0023
0024 template <class T>
0025 class aligned_storage
0026 {
0027
0028
0029 union BOOST_MAY_ALIAS dummy_u
0030 {
0031 unsigned char data[ sizeof(T) ];
0032 BOOST_DEDUCED_TYPENAME type_with_alignment<
0033 ::boost::alignment_of<T>::value >::type aligner_;
0034 } dummy_ ;
0035
0036 public:
0037
0038 #if defined(BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS)
0039 void const* address() const { return &dummy_; }
0040 void * address() { return &dummy_; }
0041 #else
0042 void const* address() const { return dummy_.data; }
0043 void * address() { return dummy_.data; }
0044 #endif
0045
0046 #if defined(BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS)
0047
0048 T const* ptr_ref() const
0049 {
0050 union { void const* ap_pvoid; T const* as_ptype; } caster = { address() };
0051 return caster.as_ptype;
0052 }
0053 T * ptr_ref()
0054 {
0055 union { void* ap_pvoid; T* as_ptype; } caster = { address() };
0056 return caster.as_ptype;
0057 }
0058 #else
0059 T const* ptr_ref() const { return static_cast<T const*>(address()); }
0060 T * ptr_ref() { return static_cast<T *> (address()); }
0061 #endif
0062
0063 T const& ref() const { return *ptr_ref(); }
0064 T & ref() { return *ptr_ref(); }
0065
0066 } ;
0067
0068 }
0069 }
0070
0071 #endif