Subject: [Boost-bugs] [Boost C++ Libraries] #5483: value_init: Assignment to 'value_initialized', 'initialized' objects doesn't work automatically
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-04-16 03:25:30
#5483: value_init: Assignment to 'value_initialized', 'initialized' objects
doesn't work automatically
-----------------------------------------------------+----------------------
Reporter: Christian Masloch <cm@â¦> | Owner: no-maintainer
Type: Bugs | Status: new
Milestone: To Be Determined | Component: utility
Version: Boost 1.46.1 | Severity: Problem
Keywords: |
-----------------------------------------------------+----------------------
Objects of the 'initialized<T>' class (and presumably
'value_initialized<T>' too) do not automatically convert to assignment
lvalues and do not provide proper assignment operator methods either.
Assignments therefore do not automatically work, for example, declaring
'initialized<int> i;' then writing 'i = 1;'.
Tested on Windows XP SP3 with MinGW g++ 4.4.1, as well as the (VS 2008)
Visual C++ 9.0 compiler. Both compilers report that no match for operator=
can be found in that assignment, and that the method 'initialized<int>&
initialized<int>::operator=(initialized<int> const&)' is considered as
'candidate' that would fit with a conversion inbetween (from 'int' to
'initialized<int>'), but it's not being used. Conversion operators such as
the one defined as 'initialized<int>::operator int&()' apparently do not
automatically qualify for lvalues either.
Workarounds specify the necessary conversion or operator method, for
example, 'i.operator int&() = 1;' and 'get(i) = 1;' both work.
The attached file contains some tests as well as a class implementing a
simplified version of the interface of 'initialized<T>' with a fix. The
file also contains the error message from g++. I omitted the one from
Visual C++ (because I would have to translate it into English) but it
essentially says the same.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/5483> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:06 UTC