Topic: Assignment to istream reference
Author: kanze@gabi-soft.de
Date: 2000/02/27 Raw View
Dietmar Kuehl <dietmar.kuehl@claas-solutions.de> writes:
|> It does not necessarily procude pretty warning messages and it only
|> work if the compiler warns for unused variables but in my IOStream
|> implementation I produce a warning in deprecated functions.
Clever.
--
James Kanze mailto:kanze@gabi-soft.de
Conseils en informatique orient e objet/
Beratung in objektorientierter Datenverarbeitung
Ziegelh ttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Dietmar Kuehl <dietmar.kuehl@claas-solutions.de>
Date: 2000/02/25 Raw View
Hi,
In article <86puts50nw.fsf@gabi-soft.de>,
kanze@gabi-soft.de wrote:
> (The Sun
> compiler generally gives an "anachronism" warning for such cases in
> the language -- I wonder how, or even if, they do this for library
> issues.)
It does not necessarily procude pretty warning messages and it only
work if the compiler warns for unused variables but in my IOStream
implementation I produce a warning in deprecated functions. This looks
like this:
template <class _CS_cT, class _CS_traits>
inline void
basic_ios<_CS_cT, _CS_traits>::exceptions(io_state _CS_s)
{
typedef bool io_state__is__deprecated;
io_state__is__deprecated use__iostate__instead;
exceptions(iostate(_CS_s));
}
If you compile this code with g++ having warnings for unused variables
turned on, you get the following error message *if* you really use this
function:
Warning [...] unused variable "io_state__is__deprecated
use__iostate__instead"
It is not pretty but at least you get something. You can turn off this
warning by not warning about unused variables.
--
<mailto:dietmar.kuehl@claas-solutions.de>
homepage: <http://www.informatik.uni-konstanz.de/~kuehl>
Sent via Deja.com http://www.deja.com/
Before you buy.
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: kanze@gabi-soft.de
Date: 2000/02/24 Raw View
Dietmar Kuehl <dietmar.kuehl@claas-solutions.de> writes:
|> In article <886e92$8mg$1@nntp3.atl.mindspring.net>,
|> "Mark Uebel" <muebel@mindspring.com> wrote:
|> > Part of my confusion is whether or not the copy
|> > constuctor is private, and whether a private assignment operator is
|> > defined.
|>
|> Both copy constructor and assignment operators are defined to be
|> private with the comment "not implemented" attached to them. In the
|> standard but I don't have a copy of the standard handy to provide
|> section and paragraph numbers.
It's worth noting, however, that while the classical implementations
never documented the fact, it generally was possible to assign to cin,
cout and cerr. Some current implementations may thus continue to
support assignment for reasons of backward compatibility. (The Sun
compiler generally gives an "anachronism" warning for such cases in the
language -- I wonder how, or even if, they do this for library issues.)
--
James Kanze mailto:kanze@gabi-soft.de
Conseils en informatique orient e objet/
Beratung in objektorientierter Datenverarbeitung
Ziegelh ttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Mark Uebel" <muebel@mindspring.com>
Date: 2000/02/14 Raw View
Hi, thanks for the reply. Part of my confusion is whether or not the copy
constuctor is private, and whether a private assignment operator is defined.
In the MSVC++ 6.0 headers, basic_ios has the following declaration:
template<class _E, class _Tr = char_traits<_E> >
class basic_ios : public ios_base {
public:
...
basic_ios(const _Myt& _R)
{init(0), *this = _R; }
...
and no asignment operator is defined. In the GNU libraries I'm using with
VxWorks (2.8.1?), both the copy constructor and the assignment operator are
declared private. I'm wondering what is "standard?" I'm also wondering
what would happen if it were valid. I'm guessing that the original object
referred to would be clobbered.
"Dietmar Kuehl" <dietmar.kuehl@claas-solutions.de> wrote in message
news:882dh0$6sp$1@nnrp1.deja.com...
> Hi,
> In article <87vrbj$b0p$1@nntp4.atl.mindspring.net>,
> "Mark Uebel" <muebel@mindspring.com> wrote:
> > Is it valid to assign to an istream reference?
>
> No, it is not: In 'std::basic_ios' the copy constructor and the
> copy assignment are defined to be private and they are never mentioned
> again later. Thus, they are not available for the classes in the
> IOStream hierarchy.
>
> > configFile = separateConfigFile; // Is this valid???
>
> You should used
>
> configFile.rdbuf(separateConfigFile.rdbuf());
>
> instead.
> --
> <mailto:dietmar.kuehl@claas-solutions.de>
> homepage: <http://www.informatik.uni-konstanz.de/~kuehl>
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
> ---
> [ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
>
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Mark Uebel" <muebel@mindspring.com>
Date: 2000/02/12 Raw View
Is it valid to assign to an istream reference? The following compiles under
VC++, but not gcc.
gcc complains that the assignment operator is private.
void example (std::istream& inputFile)
{
std::istream& configFile = inputFile; // This seems OK
std::ifstream separateConfigFile ("itsConfigFile",
ios::in|ios::nocreate);
configFile = separateConfigFile; // Is this valid???
}
Mark
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Dietmar Kuehl <dietmar.kuehl@claas-solutions.de>
Date: 2000/02/12 Raw View
Hi,
In article <87vrbj$b0p$1@nntp4.atl.mindspring.net>,
"Mark Uebel" <muebel@mindspring.com> wrote:
> Is it valid to assign to an istream reference?
No, it is not: In 'std::basic_ios' the copy constructor and the
copy assignment are defined to be private and they are never mentioned
again later. Thus, they are not available for the classes in the
IOStream hierarchy.
> configFile = separateConfigFile; // Is this valid???
You should used
configFile.rdbuf(separateConfigFile.rdbuf());
instead.
--
<mailto:dietmar.kuehl@claas-solutions.de>
homepage: <http://www.informatik.uni-konstanz.de/~kuehl>
Sent via Deja.com http://www.deja.com/
Before you buy.
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]