Topic: N2284: Missing error_code copy-ass-op - an oversight?


Author: =?iso-8859-1?q?Daniel_Kr=FCgler?= <daniel.kruegler@googlemail.com>
Date: Sun, 24 Jun 2007 09:21:42 CST
Raw View
The current draft N2284 provides in [syserr.errcode.overview] the
class
definition of the newly proposed std::error_code. This class has a
data
member of type const error_category& (exposition only) but no explicit
declaration of a copy assignment operator, which would be necessary
in this situation (if copy-assignment is wanted). The set of data
members
implies that the class is mutable (see e.g. the member

void assign(value_type val, const error_category& cat);

), the compiler-generated copy-c'tor is feasible and so it seems
astonishing
that users should not be allowed to use the natural copy-assignment
operator.

Is this implicit constraint by design or an oversight?

Greetings from Bremen,

Daniel Kr   gler


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: =?iso-8859-1?q?Daniel_Kr=FCgler?= <daniel.kruegler@googlemail.com>
Date: Sun, 24 Jun 2007 15:54:31 CST
Raw View
On 24 Jun., 17:21, Daniel Kr   gler <daniel.krueg...@googlemail.com>
wrote:
> [..] The set of data members implies that the class is mutable

Should say: function members.

> (see e.g. the member
>
> void assign(value_type val, const error_category& cat);
>
> ),

Further reflection on the class design seems to imply that
the mentioned data member cat_ of type const error_category&
must be a pointer instead of a reference, otherwise the semantics
of all mutable member functions (including the above mentioned
member assign), that is, their post-conditions along of "cat_ == ..."
seem to require that the member cat_ can be modified. This
replacement from a reference to a pointer would also resolve the
original issue concerning the missing copy-assignment operator.

Greetings from Bremen,

Daniel Kr   gler






---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: pete@versatilecoding.com (Pete Becker)
Date: Mon, 25 Jun 2007 13:44:37 GMT
Raw View
Daniel Kr=FCgler wrote:
> The current draft N2284 provides in [syserr.errcode.overview] the
> class
> definition of the newly proposed std::error_code. This class has a
> data
> member of type const error_category& (exposition only) but no explicit
> declaration of a copy assignment operator, which would be necessary
> in this situation (if copy-assignment is wanted).

It's labeled "exposition only," meaning that it doesn't have to be=20
implemented that way. In general, members that are marked "exposition=20
only" provide names for talking about how various member functions work.=20
They don't create constraints on the class itself. So if the actual=20
semantics required for a class conflict with a member marked "exposition=20
only", apply the semantics.

>=20
> Is this implicit constraint by design or an oversight?
>=20

At worst it's a minor editorial glitch. I'll take a look at it.

--=20

 -- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and=20
Reference." (www.petebecker.com/tr1book)

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]