Topic: Defect report: Impossible "as if" clauses


Author: "=?iso-8859-1?q?Daniel_Kr=FCgler?=" <daniel.kruegler@googlemail.com>
Date: Tue, 20 Feb 2007 12:07:11 CST
Raw View
The current standard 14882:2003(E) as well as N2134 have the
following
defects:

27.8.1.1/5 says:

"In order to support file I/O and multibyte/wide character
conversion,
conversions are performed using members of a facet, referred to as
a_codecvt in following sections, obtained ''as if'' by
codecvt<charT,char,typename traits::state_type> a_codecvt =
use_facet<codecvt<charT,char,typename traits::state_type>
>(getloc());"

use_facet returns a const facet reference and no facet is
copyconstructible,
so the codecvt construction should fail to compile.

A similar issue arises in 22.2.2.2.2/15 for num_punct.

Proposed resolution:
In 27.8.1.1/5 change the "as if" code from

codecvt<charT,char,typename traits::state_type> a_codecvt =
use_facet<codecvt<charT,char,typename traits::state_type> >(getloc());

to

const codecvt<charT,char,typename traits::state_type>& a_codecvt =
use_facet<codecvt<charT,char,typename traits::state_type> >(getloc());

In 22.2.2.2.2/15 (This is para 5 in N2134) change

A local variable punct is initialized via
numpunct<charT> punct = use_facet< numpunct<charT> >(str.getloc())

to

A local variable punct is initialized via
const numpunct<charT>& punct = use_facet< numpunct<charT>
>(str.getloc());

(Please note also the additional provided trailing semicolon)

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                      ]