------- Comment #3 from yuanfei8077 at gmail dot com 2006-09-29 03:02 ------- Plesae seee Comment #2 From Kelvin 2006-09-28 23:25 [reply].
In addition 2 questions I raised in the Commet2. I also have one more question about the rule "bind an rvalue to a reference, we need to let copy ctor of the class be accessible.", I found that this rule only effective when the reference is delcared as "const &", but if we remove keyword "const", then "no matching" happen again. using std::cout; using std::endl; class MemPool { public: MemPool(){}; protected: MemPool(const MemPool& mempool); }; template <class Type> class MemAllocator{ public: MemAllocator(MemPool& pool):m_pool(pool){} MemPool& get_pool() const { return m_pool; } template<class OtherType> MemAllocator<Type>& operator=(const MemAllocator<OtherType>& rhs){ m_pool = rhs.get_pool(); return *this; } MemAllocator& operator=(const MemAllocator& rhs){ m_pool = rhs.get_pool(); return *this; } MemAllocator(const MemAllocator& other) : m_pool(other.m_pool) {} template<class OtherType> MemAllocator(const MemAllocator<OtherType>& other) : m_pool(other.get_pool()) {} private: MemAllocator(); // MemAllocator(const MemAllocator&); MemPool &m_pool; }; template <class _AllocType> class tdat_hash_map { public: typedef _AllocType _Alloc; static void func(const _Alloc&) {}; tdat_hash_map(const _Alloc&); // there will be error if const is removed _Alloc malloc; private: tdat_hash_map(); }; class CacheManager { public: typedef tdat_hash_map<MemAllocator<int> > Map; Map caches; MemPool pool; CacheManager():caches(MemAllocator<int>(pool)){}; }; -- yuanfei8077 at gmail dot com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |UNCONFIRMED Resolution|INVALID | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29266