G
George
Hi All,
With gcc (3 or 4) the member template definition out of class scope
below compiles fine. But with Sun's CC 5.9, it fails with:
"main.cpp", line 7: Error: Could not find a match for Foo<T,
Policy<struct>>::bar<Foo<T, Policy<struct>>::U>(U).
This seems like a bug to me, has anyone else encountered this? Is
there any workaround beside putting the definition inside the class
decl?
Thanks much.
$ CC -V
CC: Sun C++ 5.9 Linux_i386 Patch 124865-01 2007/07/30
//main.h
#include <iostream>
#include <string>
template <typename T, template <class> class Policy >
struct Foo : Policy<T>
{
template <typename U> void bar(U u);
};
template <typename T>
class double_creator
{
T m_data;
};
//main.cpp
#include "main.h"
using namespace std;
template <typename T, template <class> class Policy >
template <typename U>
void Foo<T, Policy>::bar(U u)
{
cout << "Hello world " << u.c_str() << sizeof(T) << endl;
}
With gcc (3 or 4) the member template definition out of class scope
below compiles fine. But with Sun's CC 5.9, it fails with:
"main.cpp", line 7: Error: Could not find a match for Foo<T,
Policy<struct>>::bar<Foo<T, Policy<struct>>::U>(U).
This seems like a bug to me, has anyone else encountered this? Is
there any workaround beside putting the definition inside the class
decl?
Thanks much.
$ CC -V
CC: Sun C++ 5.9 Linux_i386 Patch 124865-01 2007/07/30
//main.h
#include <iostream>
#include <string>
template <typename T, template <class> class Policy >
struct Foo : Policy<T>
{
template <typename U> void bar(U u);
};
template <typename T>
class double_creator
{
T m_data;
};
//main.cpp
#include "main.h"
using namespace std;
template <typename T, template <class> class Policy >
template <typename U>
void Foo<T, Policy>::bar(U u)
{
cout << "Hello world " << u.c_str() << sizeof(T) << endl;
}