Matthias Klose wrote: > Hi, > > would it be possible for you to have a look at avifile to work around > #392559 by changing the avifile code? Done. If we add "template" as suggested, the compiler just gets more confused. But these member templates don't need to be doubly templated; they are only ever instantiated for the same Key and Value as the enclosing template. So we can lift them right out and avoid the problem entirely: --- avifile-0.7.44.20051021.orig/include/avm_map.h 2004-02-19 11:39:56.000000000 +0000 +++ avifile-0.7.44.20051021/include/avm_map.h 2006-10-22 01:37:30.000000000 +0000 @@ -28,47 +28,48 @@ bool operator()(const Key& k1, const Key& k2) const { return k1==k2; } }; +template <class Key, class Value> struct _avm_map_pair +{ + Key key; + Value value; + _avm_map_pair() : key(Key()), value(Value()) {} + _avm_map_pair(Key k, Value v) : key(k), value(v) {} + _avm_map_pair(const _avm_map_pair<Key, Value>& p) : key(p.key), value(p.value) {} +}; + +template <class Key, class Value> struct _avm_map_binary_tree_node +{ + _avm_map_pair<Key, Value>* entry; + _avm_map_binary_tree_node<Key, Value>* left; + Key minval; + _avm_map_binary_tree_node<Key, Value>* right; + _avm_map_binary_tree_node<Key, Value>* parent; + Key maxval; + _avm_map_binary_tree_node(_avm_map_binary_tree_node<Key, Value>* ptr=0) : entry(0), left(0), right(0), parent(ptr), weight(1) {} + int weight; + void destroy() + { + if(left) + { + left->destroy(); + delete left; + } + if(right) + { + right->destroy(); + delete right; + } + delete entry; + } +}; + // do not use this container in time critical context // search time is between log(N) and N, depending on order of element insertion template <class Key, class Value, class Compare = less<Key>, class equal = equal<Key> > class avm_map { protected: - template <class Key1, class Value1> struct pair - { - Key1 key; - Value1 value; - pair() : key(Key()), value(Value()) {} - pair(Key1 k, Value1 v) : key(k), value(v) {} - pair(const pair<Key1, Value1>& p) : key(p.key), value(p.value) {} - }; - typedef pair<Key, Value> _Tpair; - - template <class Key1, class Value1> struct binary_tree_node - { - avm_map::pair<Key1, Value1>* entry; - binary_tree_node<Key1, Value1>* left; - Key1 minval; - binary_tree_node<Key1, Value1>* right; - binary_tree_node<Key1, Value1>* parent; - Key1 maxval; - binary_tree_node(binary_tree_node<Key1, Value1>* ptr=0) : entry(0), left(0), right(0), parent(ptr), weight(1) {} - int weight; - void destroy() - { - if(left) - { - left->destroy(); - delete left; - } - if(right) - { - right->destroy(); - delete right; - } - delete entry; - } - }; - typedef binary_tree_node<Key, Value> _Tnode; + typedef _avm_map_pair<Key, Value> _Tpair; + typedef _avm_map_binary_tree_node<Key, Value> _Tnode; _Tnode* m_pTree; Value* m_pDefaultValue; @@ -190,7 +191,7 @@ template <class Key, class Value, class Compare, class Equal> avm_map<Key, Value, Compare, Equal>::avm_map() { m_pTree=new _Tnode; - m_pTree->entry = new pair<Key, Value>; + m_pTree->entry = new _Tpair; m_pDefaultValue=&(m_pTree->entry->value); } @@ -268,14 +269,14 @@ if(m_sC(ptr->entry->key, key)) { ptr->left->entry=ptr->entry; - ptr->right->entry=new pair<Key, Value>(key, value); + ptr->right->entry=new _Tpair(key, value); ptr->entry=0; update_min_max_weights(ptr); return &(ptr->right->entry->value); } else { - ptr->left->entry=new pair<Key, Value>(key, value); + ptr->left->entry=new _Tpair(key, value); ptr->right->entry=ptr->entry; ptr->entry=0; update_min_max_weights(ptr); @@ -305,14 +306,14 @@ if(!ptr->left) { ptr->left=new _Tnode(ptr); - ptr->left->entry=new pair<Key, Value>(key, value); + ptr->left->entry=new _Tpair(key, value); update_min_max_weights(ptr); return &(ptr->left->entry->value); } if(!ptr->right) { ptr->right=new _Tnode(ptr); - ptr->right->entry=new pair<Key, Value>(key, value); + ptr->right->entry=new _Tpair(key, value); update_min_max_weights(ptr); return &(ptr->right->entry->value); } -- END -- I don't know whether the resulting code works though... > Apparently that the only package in testing failing with the current > gcc-4.1. That's because we don't have enough unit tests to find the subtle code generation bugs. Ben. -- Ben Hutchings -- ben@decadentplace.org.uk shortened to ben@decadent.org.uk If you've signed my GPG key, please send a signature on and to the new uid. In a hierarchy, every employee tends to rise to his level of incompetence.
Attachment:
signature.asc
Description: This is a digitally signed message part