Ticket #2548: value_initialized_constness.patch
File value_initialized_constness.patch, 1.6 KB (added by , 14 years ago) |
---|
-
boost/utility/value_init.hpp
8 8 // 24 Dec 2007 (Refactored and worked around various compiler bugs) Fernando Cacciola, Niels Dekker 9 9 // 23 May 2008 (Fixed operator= const issue, added initialized_value) Niels Dekker, Fernando Cacciola 10 10 // 21 Ago 2008 (Added swap) Niels Dekker, Fernando Cacciola 11 // 28 Nov 2008 (Fixed logical constness) 11 12 // 12 13 #ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP 13 14 #define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP … … 90 91 wrapper_address()->wrapper::~wrapper(); 91 92 } 92 93 93 T & data() const94 T const & data() const 94 95 { 95 96 return wrapper_address()->data; 96 97 } 97 98 99 T& data() 100 { 101 return wrapper_address()->data; 102 } 103 98 104 void swap(value_initialized & arg) 99 105 { 100 106 ::boost::swap( this->data(), arg.data() ); 101 107 } 102 108 103 operator T &() const { return this->data(); }109 operator T const &() const { return this->data(); } 104 110 111 operator T&() { return this->data(); } 112 105 113 } ; 106 114 107 115 -
libs/utility/value_init_test.cpp
260 260 boost::value_initialized<T> const x_c ; 261 261 BOOST_CHECK ( y == x_c ) ; 262 262 BOOST_CHECK ( y == boost::get(x_c) ) ; 263 T& x_c_ref = x_c;263 T& x_c_ref = const_cast<T&>( boost::get(x_c) ) ; 264 264 x_c_ref = z ; 265 265 BOOST_CHECK ( x_c == z ) ; 266 266