Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:38

0001 // Copyright David Abrahams 2002.
0002 // Distributed under the Boost Software License, Version 1.0. (See
0003 // accompanying file LICENSE_1_0.txt or copy at
0004 // http://www.boost.org/LICENSE_1_0.txt)
0005 #ifndef REFERENT_STORAGE_DWA200278_HPP
0006 # define REFERENT_STORAGE_DWA200278_HPP
0007 # include <boost/mpl/if.hpp>
0008 # include <boost/type_traits/aligned_storage.hpp>
0009 # include <cstddef>
0010 
0011 namespace boost { namespace python { namespace detail {
0012 
0013 template <std::size_t size, std::size_t alignment = std::size_t(-1)>
0014 struct aligned_storage
0015 {
0016   union type
0017   {
0018     typename ::boost::aligned_storage<size, alignment>::type data;
0019     char bytes[size];
0020   };
0021 };
0022       
0023   // Compute the size of T's referent. We wouldn't need this at all,
0024   // but sizeof() is broken in CodeWarriors <= 8.0
0025   template <class T> struct referent_size;
0026   
0027   
0028   template <class T>
0029   struct referent_size<T&>
0030   {
0031       BOOST_STATIC_CONSTANT(
0032           std::size_t, value = sizeof(T));
0033   };
0034 
0035 // A metafunction returning a POD type which can store U, where T ==
0036 // U&. If T is not a reference type, returns a POD which can store T.
0037 template <class T>
0038 struct referent_storage
0039 {
0040     typedef typename aligned_storage<referent_size<T>::value, alignment_of<T>::value>::type type;
0041 };
0042 
0043 }}} // namespace boost::python::detail
0044 
0045 #endif // REFERENT_STORAGE_DWA200278_HPP