 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Jim Melton Guest
|
Posted: Tue Oct 14, 2003 8:52 am Post subject: Template default argument redefined |
|
|
template <class Key, class Value, class Compare = std::less
class oo_map;
template< class Key, class Value, class Compare = std::less
class oo_map
{
...
};
I believe it is this construct that is giving an error on the Sun Studio 8
compiler. It complains about a redefinition of a template default argument.
Assuming I didn't type any minor syntax errors above, it this a compiler bug
or a problem with the forward declaration of templates with default
arguments?
(Since the above exists in the bowels of vendor code, it is also possible
that I didn't deduce the real cause of the compiler error)
--
<disclaimer>
Opinions posted are those of the author.
My company doesn't pay me enough to speak for them.
</disclaimer>
--
Jim Melton
Software Architect, Fusion Programs
Lockheed Martin Astronautics
(303) 971-3846
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
tom_usenet Guest
|
Posted: Tue Oct 14, 2003 9:07 pm Post subject: Re: Template default argument redefined |
|
|
On 14 Oct 2003 04:52:56 -0400, Jim Melton <jim.melton (AT) lmco (DOT) com> wrote:
| Quote: | template <class Key, class Value, class Compare = std::less
class oo_map;
template< class Key, class Value, class Compare = std::less
|
should be:
template< class Key, class Value, class Compare>
| Quote: | class oo_map
{
...
};
I believe it is this construct that is giving an error on the Sun Studio 8
compiler. It complains about a redefinition of a template default argument.
Assuming I didn't type any minor syntax errors above, it this a compiler bug
or a problem with the forward declaration of templates with default
arguments?
|
As with function default arguments, you should may only specify a
default template argument in one declaration.
Tom
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Christoph Schulz Guest
|
Posted: Wed Oct 22, 2003 1:27 am Post subject: Re: Template default argument redefined |
|
|
Hello!
Jim Melton <jim.melton (AT) lmco (DOT) com> wrote:
| Quote: | template
class oo_map;
template< class Key, class Value, class Compare = std::less
class oo_map
{
...
};
I believe it is this construct that is giving an error on the Sun
Studio 8 compiler. It complains about a redefinition of a template
default argument. Assuming I didn't type any minor syntax errors
above, it this a compiler bug or a problem with the forward
declaration of templates with default arguments?
|
The standard says in 14.1/10:
The set of default template arguments available for use with
a template declaration or definition is obtained by merging
the default arguments from the definition (if in scope) and
all declarations in scope in the same way default function
arguments are (8.3.6).
Since 8.3.6/4 forbids redefinition of default arguments ("A default
argument shall not be redefined by a later declaration (not even
to the same value)."), your example is not valid C++, and the
Sun compiler is right to reject it.
Regards,
Christoph
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|