Topic: Wish List
Author: thurni@bigpond.com ("Nick Thurn")
Date: Tue, 25 Feb 2003 18:09:34 +0000 (UTC) Raw View
From: "LLeweLLyn" <llewelly.at@xmission.dot.com>
> thurni@bigpond.com ("Nick Thurn") writes:
> [snip]
> > - make iostreams forward declarable again
> [snip]
>
> What about <iosfwd> ?
>
I was refering to changing the typedefs into classes
or structs that can *really* be forward declared and
easily placed in a library.
namespace std { class ostream; class istream; class string; }
<iosfwd> is an admission that gratuitously templatizing
iostreams was a mistake. IMHO anyway.
Perhaps I took Lakos too much to heart as a lad ;-\
cheers
Nick
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]
Author: "Philippe Mori" <philippe_mori@hotmail.com>
Date: Tue, 25 Feb 2003 16:24:41 CST Raw View
> > > - make iostreams forward declarable again
> >
> > What about <iosfwd> ?
> >
>
> I was refering to changing the typedefs into classes
> or structs that can *really* be forward declared and
> easily placed in a library.
>
> namespace std { class ostream; class istream; class string; }
>
> <iosfwd> is an admission that gratuitously templatizing
> iostreams was a mistake. IMHO anyway.
>
> Perhaps I took Lakos too much to heart as a lad ;-\
>
> cheers
> Nick
>
>
I also think that we should be able to forward declare these
classes but I am not sure if we can or should uses the current
syntax for typedef'ed names (like those above). I think that it
is better that using class (or struct) for a forward declaration
really means that we have a class (or struct). This help ensure
that the compiler can detect more inconsistencies or others
problems.
What I think is that we should uses typename keyword for any
forward declaration that would otherwise need more information
to compile (or worst could be compiler depedant).
For example, we should be able to do:
namespace std {
typename ostream;
typename istream;
typename string;
}
If this is not possible or not desired to have completly free
forward declarations, we may require to add proper keyword
at appropriate places like that:
namespace std { typename typedef ostream; }
We should also be able to forward nested classes. In this case
we also have the same 2 possibilities:
namespace N { typename Outer::Inner; }
or
namespace N { typename class Outer :: class Inner; }
IMHO, the simplified syntax (uses only typename keyword)
would be preferable but the other syntax could be used if
this is not desirable...
Note that in the last example, we may prefer the syntax to be
namespace N { typename class Outer::Inner; }
since Outer must be a struct or class (or union) and it probably
never matters --- In fact, it cannot be a namespace currently (and
I think we should not allows it because it helps argument for
lookup purpose when searching candidate functions for some args).
Also we may support or not using typename for forward
declaration on a type that is a typedef to an enum or
basic type (or a pointer, a reference,...). Also, I'm not sure
we should or not allows some modifier to be hidden in a
forward-declarared typedef.
One one side, we would have simplicity (a forward declared
typename is a class, a struct or an union (or a typedef of that))
and on the other side we would have generality. Anything can
be forward-declared... In that latter case, depending on the
number of attributes that must be specified (pointer, ref, const)
on the forward declaration, we define the limit when real
information is required for the code to compile.
An example:
template <typename T> void f(T &r) { f1(r); }
template <typename T> void f(const T &r) { f2(r); }
template <typename T> void f(T *p) { f3(p); }
typename MyType;
MyType *p = GetObject();
f(*p);
Here, if we knows that MyType is not a typedef to a pointer
(and not const), we knows that we must call f1. If f1 is declared
for MyType, then we do not need more information on MyType
to compile that unit (if f1 is defined in another compilation unit).
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]
Author: "White Wolf" <wolof@freemail.hu>
Date: Tue, 25 Feb 2003 16:31:48 CST Raw View
""Nick Thurn"" wrote:
> I was refering to changing the typedefs into classes
> or structs that can *really* be forward declared and
> easily placed in a library.
>
> namespace std { class ostream; class istream; class string; }
You are not allowed to place *anything* into namespace std, so I guess
even if those streams would not be templates you could not do that. I
mean you can, but it is not allowed.
WW
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]
Author: dheld@codelogicconsulting.com ("David B. Held")
Date: Tue, 25 Feb 2003 22:49:45 +0000 (UTC) Raw View
"White Wolf" <wolof@freemail.hu> wrote in message
news:b3gikq$j81$1@phys-news1.kolumbus.fi...
> [...]
> You are not allowed to place *anything* into namespace std, so I
> guess even if those streams would not be templates you could not
> do that. I mean you can, but it is not allowed.
What about specializations of std::less<>?
Dave
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]