Vram Vardanian
Vram Vardanian

Reputation: 579

gcc: wrong number of template arguments

Why this code compiles succesfully in VS13 and fails to compile by gcc?

/////    file my_map.h /////

namespace my 
{
    // my custom map
    template<typename K, typename V, typename order = less<K>, typename allocator = cached_alloc<page_allocator<pair<K,V> > > >
    class map : public set_base<pair<K, V>, K, select1st, order, ins_unique, allocator>
    {
        ...
    };
}

/////    file test.h /////

#include "my_map.h"

template <typename T>    
class Base
{
protected:
    typedef my::map<T, double> MyMap;
    MyMap m_map;                                // this is line NN

public:
    void func(const T& key)
    {
        typename MyMap::iterator it = m_map.find(key);
        if(it != m_map.end()) {
            // ....
        }
    }
};

class Inherited1 : public Base <char>
{ };
class Inherited2 : public Base <int>
{ };

It results in following errors (gcc 4.1.2)

filepath.h:LineNN error: wrong number of template arguments (1, should be 4)
..: error: provided for 'template<class K, class V, class order, class allocator> class my::map'

It is not clear for me what compiler actually means by "wrong number of template arguments "?

Upvotes: 0

Views: 766

Answers (1)

ypnos
ypnos

Reputation: 52367

The compiler you are using is too old. Gcc 4.1.2 was released seven years ago. It had bugs just as the old VC compilers of that era. It is hard to find the problem as new compilers work fine. Try updating your compiler.

Upvotes: 1

Related Questions