[aspectc-user] Multiple definitions error with templates.

Guilherme . guibufolo at gmail.com
Mon Jun 27 17:59:47 CEST 2011


Hi!

I am getting following error when trying to weave my code:

include//click/hashmap.hh:219: error: invalid declaration near token
`template'

Maybe this error has to do with the previously submitted email about the
conversion operator.

Here is the offending code:

219 template <class K, class V>
220 inline
221 _HashMap_const_iterator<K, V>::operator unspecified_bool_type() const
222 {
223     return live() ? &_HashMap_const_iterator::live : 0;
224 }

And the next one in this file:

include//click/hashmap.hh:366: error: redefinition of `HashMap::begin'
include//click/hashmap.hh:67: previously defined here
include//click/hashmap.hh:534: error: redefinition of `HashMap::begin'

The interesting part is, that it uses template specialization to (with g++)
avoid these errors.

There are two classes defined.

First:
 24 template <class K, class V>
 25 class HashMap { public:

With forward declaration:
 67   inline const_iterator begin() const;

115 };

and later on:

And the second class (the specializaton)

227 template <class K>
228 class HashMap<K, void *> { public:

318 };

with these begin functions:

364 template <class K>
365 inline typename HashMap<K, void *>::const_iterator
366 HashMap<K, void *>::begin() const
367 {
368   return const_iterator(this, true);
369 }

532 template <class K, class T>
533 inline typename HashMap<K, T *>::const_iterator
534 HashMap<K, T *>::begin() const
535 {
536   return const_iterator(this, true);
537 }

So i guess the specialization must be throwing the ac++ parser off...

Anything i can do about it?

Thank you for your help,
Guilherme
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.aspectc.org/pipermail/aspectc-user/attachments/20110627/c6c8cdc7/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hashmap.hh
Type: text/x-c++hdr
Size: 15396 bytes
Desc: not available
URL: <http://www.aspectc.org/pipermail/aspectc-user/attachments/20110627/c6c8cdc7/attachment.hh>


More information about the aspectc-user mailing list