diff --git a/include/boost/utility/swap.hpp b/include/boost/utility/swap.hpp index 6845e79..5ee6dc1 100644 --- a/include/boost/utility/swap.hpp +++ b/include/boost/utility/swap.hpp @@ -21,12 +21,15 @@ // avoid ambiguity when swapping objects of a Boost type that does // not have its own boost::swap overload. -#include //for std::swap +#include //for std::swap (C++11) +#include //for std::swap (C++98) #include //for std::size_t +#include namespace boost_swap_impl { template + BOOST_GPU_ENABLED void swap_impl(T& left, T& right) { using namespace std;//use std::swap if argument dependent lookup fails @@ -34,6 +37,7 @@ namespace boost_swap_impl } template + BOOST_GPU_ENABLED void swap_impl(T (& left)[N], T (& right)[N]) { for (std::size_t i = 0; i < N; ++i) @@ -46,6 +50,7 @@ namespace boost_swap_impl namespace boost { template + BOOST_GPU_ENABLED void swap(T1& left, T2& right) { ::boost_swap_impl::swap_impl(left, right); diff --git a/include/boost/utility/value_init.hpp b/include/boost/utility/value_init.hpp index 2e43287..9d8de70 100644 --- a/include/boost/utility/value_init.hpp +++ b/include/boost/utility/value_init.hpp @@ -71,12 +71,14 @@ class initialized #endif remove_const::type data; + BOOST_GPU_ENABLED wrapper() : data() { } + BOOST_GPU_ENABLED wrapper(T const & arg) : data(arg) @@ -90,6 +92,7 @@ class initialized #endif aligned_storage::value>::type x; + BOOST_GPU_ENABLED wrapper * wrapper_address() const { return static_cast( static_cast(&x)); @@ -97,6 +100,7 @@ class initialized public : + BOOST_GPU_ENABLED initialized() { #if BOOST_DETAIL_VALUE_INIT_WORKAROUND @@ -105,16 +109,19 @@ class initialized new (wrapper_address()) wrapper(); } + BOOST_GPU_ENABLED initialized(initialized const & arg) { new (wrapper_address()) wrapper( static_cast(*(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. @@ -123,31 +130,37 @@ class initialized 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; @@ -156,18 +169,21 @@ class initialized } ; template +BOOST_GPU_ENABLED T const& get ( initialized const& x ) { return x.data() ; } template +BOOST_GPU_ENABLED T& get ( initialized& x ) { return x.data() ; } template +BOOST_GPU_ENABLED void swap ( initialized & lhs, initialized & rhs ) { lhs.swap(rhs) ; @@ -183,31 +199,37 @@ class value_initialized 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; @@ -216,18 +238,21 @@ class value_initialized template +BOOST_GPU_ENABLED T const& get ( value_initialized const& x ) { return x.data() ; } template +BOOST_GPU_ENABLED T& get ( value_initialized& x ) { return x.data() ; } template +BOOST_GPU_ENABLED void swap ( value_initialized & lhs, value_initialized & rhs ) { lhs.swap(rhs) ; @@ -238,7 +263,7 @@ class initialized_value_t { public : - template operator T() const + template BOOST_GPU_ENABLED operator T() const { return initialized().data(); }