diff options
Diffstat (limited to '3rdParty/Boost/src/boost/utility/value_init.hpp')
-rw-r--r-- | 3rdParty/Boost/src/boost/utility/value_init.hpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/3rdParty/Boost/src/boost/utility/value_init.hpp b/3rdParty/Boost/src/boost/utility/value_init.hpp index 5de9585..9d8de70 100644 --- a/3rdParty/Boost/src/boost/utility/value_init.hpp +++ b/3rdParty/Boost/src/boost/utility/value_init.hpp @@ -30,21 +30,19 @@ #include <boost/swap.hpp> #include <cstring> #include <new> #ifdef BOOST_MSVC #pragma warning(push) -#if _MSC_VER >= 1310 // It is safe to ignore the following warning from MSVC 7.1 or higher: // "warning C4351: new behavior: elements of array will be default initialized" #pragma warning(disable: 4351) // It is safe to ignore the following MSVC warning, which may pop up when T is // a const type: "warning C4512: assignment operator could not be generated". #pragma warning(disable: 4512) #endif -#endif #ifdef BOOST_NO_COMPLETE_VALUE_INITIALIZATION // Implementation detail: The macro BOOST_DETAIL_VALUE_INIT_WORKAROUND_SUGGESTED // suggests that a workaround should be applied, because of compiler issues // regarding value-initialization. #define BOOST_DETAIL_VALUE_INIT_WORKAROUND_SUGGESTED @@ -70,18 +68,20 @@ class initialized { #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) typename #endif remove_const<T>::type data; + BOOST_GPU_ENABLED wrapper() : data() { } + BOOST_GPU_ENABLED wrapper(T const & arg) : data(arg) { } }; @@ -89,90 +89,104 @@ class initialized mutable #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) typename #endif aligned_storage<sizeof(wrapper), alignment_of<wrapper>::value>::type x; + BOOST_GPU_ENABLED wrapper * wrapper_address() const { return static_cast<wrapper *>( static_cast<void*>(&x)); } public : + BOOST_GPU_ENABLED initialized() { #if BOOST_DETAIL_VALUE_INIT_WORKAROUND std::memset(&x, 0, sizeof(x)); #endif new (wrapper_address()) wrapper(); } + BOOST_GPU_ENABLED initialized(initialized const & arg) { new (wrapper_address()) wrapper( static_cast<wrapper const &>(*(arg.wrapper_address()))); } + BOOST_GPU_ENABLED explicit initialized(T const & arg) { new (wrapper_address()) wrapper(arg); } + BOOST_GPU_ENABLED initialized & operator=(initialized const & arg) { // Assignment is only allowed when T is non-const. BOOST_STATIC_ASSERT( ! is_const<T>::value ); *wrapper_address() = static_cast<wrapper const &>(*(arg.wrapper_address())); return *this; } + BOOST_GPU_ENABLED ~initialized() { wrapper_address()->wrapper::~wrapper(); } + BOOST_GPU_ENABLED T const & data() const { return wrapper_address()->data; } + BOOST_GPU_ENABLED T& data() { return wrapper_address()->data; } + BOOST_GPU_ENABLED void swap(initialized & arg) { ::boost::swap( this->data(), arg.data() ); } + BOOST_GPU_ENABLED operator T const &() const { return wrapper_address()->data; } + BOOST_GPU_ENABLED operator T&() { return wrapper_address()->data; } } ; template<class T> +BOOST_GPU_ENABLED T const& get ( initialized<T> const& x ) { return x.data() ; } template<class T> +BOOST_GPU_ENABLED T& get ( initialized<T>& x ) { return x.data() ; } template<class T> +BOOST_GPU_ENABLED void swap ( initialized<T> & lhs, initialized<T> & rhs ) { lhs.swap(rhs) ; } template<class T> @@ -182,68 +196,77 @@ class value_initialized // initialized<T> does value-initialization by default. initialized<T> m_data; public : + BOOST_GPU_ENABLED value_initialized() : m_data() { } + BOOST_GPU_ENABLED T const & data() const { return m_data.data(); } + BOOST_GPU_ENABLED T& data() { return m_data.data(); } + BOOST_GPU_ENABLED void swap(value_initialized & arg) { m_data.swap(arg.m_data); } + BOOST_GPU_ENABLED operator T const &() const { return m_data; } + BOOST_GPU_ENABLED operator T&() { return m_data; } } ; template<class T> +BOOST_GPU_ENABLED T const& get ( value_initialized<T> const& x ) { return x.data() ; } template<class T> +BOOST_GPU_ENABLED T& get ( value_initialized<T>& x ) { return x.data() ; } template<class T> +BOOST_GPU_ENABLED void swap ( value_initialized<T> & lhs, value_initialized<T> & rhs ) { lhs.swap(rhs) ; } class initialized_value_t { public : - template <class T> operator T() const + template <class T> BOOST_GPU_ENABLED operator T() const { return initialized<T>().data(); } }; initialized_value_t const initialized_value = {} ; |