This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/4265: No match for template function with template template parameter.



>Number:         4265
>Category:       c++
>Synopsis:       No match for template function with template template parameter.
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 07 20:56:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Carlo Wood
>Release:        g++ 3.0.1
>Organization:
>Environment:
i686-unknown-gnu-linux
>Description:
The compiler doesn't find a match for a template
function that uses a template template parameter.
>How-To-Repeat:
I did run into this using the following program:

#include <iostream>
#include <map>
 
using namespace std;
 
class memblk_key_ct {
private:
  int M_k;
public:
  memblk_key_ct(int k) : M_k(k) { }
  bool operator<(memblk_key_ct b) const { return M_k < b.M_k; }
};
class memblk_info_ct {
private:
  int M_i;
public:
  memblk_info_ct(int i) : M_i(i) { }
};
 
typedef map<memblk_key_ct, memblk_info_ct, less<memblk_key_ct> > memblk_map_ct;
typedef pair<memblk_key_ct const, memblk_info_ct> memblk_ct;
typedef memblk_map_ct volatile volatile_memblk_map_ct;
 
#define AcquireWriteLock(x,y) const_cast<memblk_map_ct*>(x)
#define AcquireReadLock(x,y) const_cast<memblk_map_ct const*>(x)
 
template<template<typename X, typename R, typename P> class iterator, class T>
  iterator<T, T&, T*>& map_iterator_const_cast (iterator<T, T const&, T const*> const&)
  {
    static iterator<T, T&, T*> foo;
    return foo;
  }
 
int main(void)
{
  memblk_map_ct const volatile* memblk_map;
  memblk_ct memblk(memblk_key_ct(0), memblk_info_ct(1));
 
  pair<memblk_map_ct::iterator, bool> const& iter1(AcquireWriteLock(memblk_map, rwlock)->insert(memblk));
  memblk_map_ct::const_iterator const& iter2(AcquireReadLock(memblk_map, rwlock)->find(memblk_key_ct(0)));
 
  memblk_map_ct::iterator& iter3(map_iterator_const_cast<memblk_map_ct::iterator&>(iter2));
 
  return 0;
}


The compiler gives the following error:

~>g++-3.0.1 -v test.cc
Reading specs from /usr/local/gcc-3.0.1/lib/gcc-lib/i686-pc-linux-gnu/3.0.1/specs
Configured with: /usr/src/gcc/gcc-3.0.1/configure --prefix=/usr/local/gcc-3.0.1 --enable-shared --with-gnu-as --with-gnu-ld --enable-languages=c++ --enable-debug --enable-threads
Thread model: posix
gcc version 3.0.1
 /usr/local/gcc-3.0.1/lib/gcc-lib/i686-pc-linux-gnu/3.0.1/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=1 -D__ELF__ -Dunix
-Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ test.cc -D__GNUG__=3 -D__GXX_DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -quiet -dumpbase test.cc -version -o /tmp/ccaZZpPx.s
GNU CPP version 3.0.1 (cpplib) (i386 Linux/ELF)
GNU C++ version 3.0.1 (i686-pc-linux-gnu)
        compiled by GNU C version 3.0.1.
ignoring nonexistent directory "/usr/local/gcc-3.0.1/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/gcc-3.0.1/include/g++-v3
 /usr/local/gcc-3.0.1/include/g++-v3/i686-pc-linux-gnu
 /usr/local/gcc-3.0.1/include/g++-v3/backward
 /usr/local/include
 /usr/local/gcc-3.0.1/lib/gcc-lib/i686-pc-linux-gnu/3.0.1/include
 /usr/include
End of search list.
test.cc: In function `int main()':
test.cc:42: no matching function for call to `map_iterator_const_cast(const
   std::_Rb_tree_iterator<std::pair<const memblk_key_ct, memblk_info_ct>, const
   std::pair<const memblk_key_ct, memblk_info_ct>&, const std::pair<const
   memblk_key_ct, memblk_info_ct>*>&)'

I believe this to be an error because it should
match with `iterator' == std::_Rb_tree_iterator
and `T' == std::pair<const memblk_key_ct, memblk_info_ct>
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]