Article View: comp.std.c++
Article #2632Re: Template questions
From: Steve Clamage
Date: Fri, 17 Nov 1995 17:39
Date: Fri, 17 Nov 1995 17:39
40 lines
1911 bytes
1911 bytes
In article itn@lhc.nlm.nih.gov, bkline@cortex.nlm.nih.gov (Bob Kline) writes:
>A couple of questions about situations in which I'm not sure why
>the compiler (Sun's CC in this case) is rejecting some template code.
>The first case involves the following code:
>template<size_t N> class bitset { ... };
>bitset<6> bs;
>
>The compiler complains:
> Error: Template parameter N requires an expression of type unsigned.
The ARM disallowed conversions in template arguments. The draft standard
allows various conversions. The latest Sun compiler accepts this code.
(See about upgrading your compiler to the 4.1 release.)
>Here's the other case:
>template<size_t N>
>bitset<N> operator&(const bitset<N>& lhs, const bitset<N>& rhs)
>{
> return bitset<N>(lhs) &= rhs;
>}
>To which the compiler responds:
>
>"./bitset", line 333: Error: The template argument N is not a type.
Non-type template arguments for template functions are a recent
addition to the language. The current Sun compilers do not support
that feature. The next major release will support them.
---
Steve Clamage, stephen.clamage@eng.sun.com
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<48ig8h$mgf@engnews1.eng.sun.com>Path:
arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamageReferences:
<48e62h$itn@lhc.nlm.nih.gov>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage From: clamage@Eng.sun.com (Steve Clamage) Newsgroups: comp.std.c++ Subject: Re: Template questions Date: 17 Nov 1995 17:39:03 GMT Organization: Sun Microsystems Inc. Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <48ig8h$mgf@engnews1.eng.sun.com> References: <48e62h$itn@lhc.nlm.nih.gov> Reply-To: clamage@Eng NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text X-Nntp-Posting-Host: taumet.eng.sun.com Content-Length: 1116 X-Lines: 36 Originator: clamage@taumet