Topic: Use of the "export" keyword
Author: Patrick =?iso-8859-1?Q?M=E9rissert=2DCoffini=E8res?= <pamc@club-internet.fr>
Date: 1999/03/14 Raw View
As you may see, I have tried in my answer to Francis Glassborow to clear away the
confusion in my former postings. As a matter of fact I bought the C++PL about one year
ago in Paris, but it _is_ a 3rd edition anyway, so I don't think I should be missing
anything?
Inasmuch as there is, as far as I know, no "reference compiler", knowing whether a
given construct is or is not allowed by the standard is not always easy, even now when
I have bought a copy of the standard itself. The postings on groups such as this are of
course a source of information, and one of the postings directed me to the Blitz
compilers testing suite, but it only tests a list of constructs that are necessary for
those libraries. Even so I got answers to a lot of other such questions that way, but I
wonder whether the notion of a site with a reference syntax-checker would make some
sense?
Patrick M rissert-Coffini res
Bjarne Stroustrup wrote:
>
> There were about 6 minor changes to the draft standard between the
> publication of "The C++ Programming Language (3rd Edition)" and the
> final standard. They were all corrected in early printings of my book
> and documented in the errata. Unless you bought your copy more than
> a year ago there are no discrepancies.
>
> No book is - or could be - more up to date on Standard C++
> (ISO/IEC 14882, Standard for the C++ Programming Language).
>
> Partial specialization was introduced a couple of years ago and the
> description of partial specialization in "The C++ Programming Language
> (3rd Edition)" is and always were in accordance with the standard.
> That is, you were (again) mistaken in your conjecture that "The C++
> Programming Language (3rd Edition)" didn't accurately reflect the
> standard.
>
> - Bjarne
> Bjarne Stroustrup - http://www.research.att.com/~bs
[ 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: Patrick =?iso-8859-1?Q?M=E9rissert=2DCoffini=E8res?= <pamc@club-internet.fr>
Date: 1999/03/14 Raw View
Sorry, I realize I have been expressing myself imprecisely, and even, as =
regards
"partial specialization", confusedly! What I was wondering at the time wa=
s whether
it was possible given e template with 2 arguments to totally specialize t=
he second
one, while leaving the first one fully general (for instance,
template<int K,int N> class Power {
public:
enum {value=3DPower<K,N-1>*K};
};
template<int K> class Power<K,0>
{
public:
enum {value=3D1};
};
). I had not been able to find a direct example of this in the C++PL 3r=
d ed, I was
not sure whether it was possible, if it was, I was not sure whether I wa=
s trying
the right syntax, and if I was, I was not sure whether the compilers at m=
y disposal
would recognize it! When I saw examples in the Primer, I assumed (wrongly=
as you
have now informed me), that a language extension had take place at that t=
ime.
Thanks for the enlightenment :-)
Patrick M=E9rissert-Coffini=E8res
Francis Glassborow wrote:By the time BS published the standard was very
substantially in place
> (we were deep in the phase of resolving National Body comments at which
> stage no new material can be introduced) Partial Specialisation was wa=
y
> before that. Check page 342 of The C++PL 3rd ed.
---
[ 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: Patrick =?iso-8859-1?Q?M=E9rissert=2DCoffini=E8res?= <pamc@club-internet.fr>
Date: 1999/03/08 Raw View
Of course, but I was not alluding to mistakes on the part of anybody (myself I
have not noticed any in either of the books), but only to the changes made by
the committee between the times the two books were written: for instance, unless
I am mistaken, it had not yet been decided to include partial specialization of
templates in the standard when Stroustrup book was written, so the
Lippman/Lajoie book was the first one where I saw it demonstrated. When I read
it I had been wondering whether it was allowed,and if so, what was the exact
syntax, so I was very happy to discover the answer in that book!
>
> The degree to which Stroustrup's book varies from the standard is minute
> and probably no more than Lippman/Lajoie. The degree to which
> Stroustrup's book was technically reviewed was quite exceptional and
> should be respected. That is not to denigrate Lippman/Lajoie because I
> also hold that book in high regard and I am sure that Lajoie would never
> have consciously let anything slip but despite her encyclopaedic
> knowledge of the language part of the standard she is as prone to error
> as any other expert.
>
> Francis Glassborow Chair of Association of C & C++ Users
> 64 Southfield Rd
> Oxford OX4 1PA +44(0)1865 246490
> All opinions are mine and do not represent those of any organisation
>
[ 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: Francis Glassborow <francis@robinton.demon.co.uk>
Date: 1999/03/08 Raw View
In article <36E31416.8A62E414@club-internet.fr>, Patrick M rissert-
Coffini res <pamc@club-internet.fr> writes
>Of course, but I was not alluding to mistakes on the part of anybody (myself I
>have not noticed any in either of the books), but only to the changes made by
>the committee between the times the two books were written: for instance, unless
>I am mistaken, it had not yet been decided to include partial specialization of
>templates in the standard when Stroustrup book was written, so the
>Lippman/Lajoie book was the first one where I saw it demonstrated. When I read
>it I had been wondering whether it was allowed,and if so, what was the exact
>syntax, so I was very happy to discover the answer in that book!
By the time BS published the standard was very substantially in place
(we were deep in the phase of resolving National Body comments at which
stage no new material can be introduced) Partial Specialisation was way
before that. Check page 342 of The C++PL 3rd ed.
Francis Glassborow Chair of Association of C & C++ Users
64 Southfield Rd
Oxford OX4 1PA +44(0)1865 246490
All opinions are mine and do not represent those of any organisation
[ 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: bs@research.att.com (Bjarne Stroustrup)
Date: 1999/03/08 Raw View
Patrick =?iso-8859-1?Q?M=E9rissert=2DCoffini=E8res?= <pamc@club-internet.fr> writes:
> Of course, but I was not alluding to mistakes on the part of anybody
> (myself I have not noticed any in either of the books), but only to
> the changes made by the committee between the times the two books were
> written: for instance, unless I am mistaken, it had not yet been decided
> to include partial specialization of templates in the standard when
> Stroustrup book was written, so the Lippman/Lajoie book was the first
> one where I saw it demonstrated. When I read it I had been wondering
> whether it was allowed,and if so, what was the exact syntax, so I was
> very happy to discover the answer in that book!
There were about 6 minor changes to the draft standard between the
publication of "The C++ Programming Language (3rd Edition)" and the
final standard. They were all corrected in early printings of my book
and documented in the errata. Unless you bought your copy more than
a year ago there are no discrepancies.
No book is - or could be - more up to date on Standard C++
(ISO/IEC 14882, Standard for the C++ Programming Language).
Partial specialization was introduced a couple of years ago and the
description of partial specialization in "The C++ Programming Language
(3rd Edition)" is and always were in accordance with the standard.
That is, you were (again) mistaken in your conjecture that "The C++
Programming Language (3rd Edition)" didn't accurately reflect the
standard.
> > The degree to which Stroustrup's book varies from the standard is minute
> > and probably no more than Lippman/Lajoie. The degree to which
> > Stroustrup's book was technically reviewed was quite exceptional and
> > should be respected. That is not to denigrate Lippman/Lajoie because I
> > also hold that book in high regard and I am sure that Lajoie would never
> > have consciously let anything slip but despite her encyclopaedic
> > knowledge of the language part of the standard she is as prone to error
> > as any other expert.
> >
> > Francis Glassborow Chair of Association of C & C++ Users
- Bjarne
Bjarne Stroustrup - http://www.research.att.com/~bs
[ 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: Patrick =?iso-8859-1?Q?M=E9rissert=2DCoffini=E8res?= <pamc@club-internet.fr>
Date: 1999/03/06 Raw View
I think nobody implements the export keyword yet, certainly not microsoft,
but not even egcs 1.1, the latest offspring of the gnu compiler, which I
think is the most compliant c++ compiler at the moment. I am not sure about
borland, anyway you would need to put the export keyword in the header file
(out.h) to stand a chance.
A book like Lippman/Lajoie's C++ Primer (3rd edition), that gives the most
helpful comments about the final standard (Stroustrup's book was written
before that, and the language has changed somewhat since), makes it clear
that you should not expect what he calls "the separate compilation model" of
templates to be required of compliant compilers, at least any time soon. Of
course it is a pity, since it is needed to avoid putting the totality of a
template implementation in publicly visible header files, and that's why
they introduced it, but implementing is is non-trivial, and it would
probably delay too long the general availability of otherwise compilant
compilers to insist upon it.
By the way, microsoft (C++6) implements a non-comformant, undocumented, and
specialized version of it (they would):
for a total specialization of a class template (I don't know about function
templates?) you can declare it using the extern keyword.
They use it to hide their implementation of the class std::string as a
total specialization of basic_string:
Sean Shubin wrote:
> Is it the code, or the compilers that are not compliant with the C++
> Standard?
> When I compile this code using C++Builder4, the linker reports an
> unresolved external "void out<double>(const double&)".
> When I compile this code using Microsoft Visual C++ 6.0, the compiler
> reports "syntax error : missing ';' before ''template<'" for the line
> "export template <class T> void out(const T& t) { std::cerr << t; }".
> Here is the code:
> //FILE: test.cpp
> #include "out.h"
> int main(int argc, char* argv[])
> {
> double x = 1.23;
> out(x);
> return 0;
> }
> //FILE: out.h
> template <class T> void out(const T& t);
> //FILE: out.cpp
> #include <iostream>
> #include "out.h"
> export template <class T> void out(const T& t) { std::cerr << t; }
> I got this code from the book "The C++ Programming Language / Bjarne
> Stroustrup . --3rd. ed." Section 13.7.
> It looks like Microsoft does not recognize the "export" keyword and
> borland just ignores it.
[ 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: Francis Glassborow <francis@robinton.demon.co.uk>
Date: 1999/03/07 Raw View
In article <36E1519C.5C251DDE@club-internet.fr>, Patrick M=E9rissert-
Coffini=E8res <pamc@club-internet.fr> writes
>A book like Lippman/Lajoie's C++ Primer (3rd edition), that gives the mo=
st
>helpful comments about the final standard (Stroustrup's book was written
>before that, and the language has changed somewhat since), makes it clea=
r
>that you should not expect what he calls "the separate compilation model=
" of
>templates to be required of compliant compilers, at least any time soon.=
Of
>course it is a pity, since it is needed to avoid putting the totality of=
a
>template implementation in publicly visible header files, and that's why
>they introduced it, but implementing is is non-trivial, and it would
>probably delay too long the general availability of otherwise compilant
>compilers to insist upon it.
The degree to which Stroustrup's book varies from the standard is minute
and probably no more than Lippman/Lajoie. The degree to which
Stroustrup's book was technically reviewed was quite exceptional and
should be respected. That is not to denigrate Lippman/Lajoie because I
also hold that book in high regard and I am sure that Lajoie would never
have consciously let anything slip but despite her encyclopaedic
knowledge of the language part of the standard she is as prone to error
as any other expert.
Francis Glassborow Chair of Association of C & C++ Users
64 Southfield Rd
Oxford OX4 1PA +44(0)1865 246490
All opinions are mine and do not represent those of any organisation
---
[ 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: sean.shubin@nospam.integtech.com (Sean Shubin)
Date: 1999/03/03 Raw View
Is it the code, or the compilers that are not compliant with the C++
Standard?
When I compile this code using C++Builder4, the linker reports an
unresolved external "void out<double>(const double&)".
When I compile this code using Microsoft Visual C++ 6.0, the compiler
reports "syntax error : missing ';' before ''template<'" for the line
"export template <class T> void out(const T& t) { std::cerr << t; }".
Here is the code:
//FILE: test.cpp
#include "out.h"
int main(int argc, char* argv[])
{
double x = 1.23;
out(x);
return 0;
}
//FILE: out.h
template <class T> void out(const T& t);
//FILE: out.cpp
#include <iostream>
#include "out.h"
export template <class T> void out(const T& t) { std::cerr << t; }
I got this code from the book "The C++ Programming Language / Bjarne
Stroustrup . --3rd. ed." Section 13.7.
It looks like Microsoft does not recognize the "export" keyword and
borland just ignores it.
---
[ 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 ]