template

F

Fraser Ross

#include <list>
#include <memory>
#pragma hdrstop
template<
typename T1=int,
typename T2=double,
template<typename, typename> class Container=
std::list<T1, std::allocator<T1> > >
class Relation {
Container dom1;
};
#pragma argsused
int main(int argc, char* argv[])
{
Relation<> rel;
return 0;
}

Why do I get an undefined structure error for rel? Probably its a compiler
bug or a language feature not implemented.

Fraser.
 
J

John Harrison

Fraser said:
#include <list>
#include <memory>
#pragma hdrstop
template<
typename T1=int,
typename T2=double,
template<typename, typename> class Container=
std::list<T1, std::allocator<T1> > >
class Relation {
Container dom1;
};
#pragma argsused
int main(int argc, char* argv[])
{
Relation<> rel;
return 0;
}

Why do I get an undefined structure error for rel? Probably its a compiler
bug or a language feature not implemented.

No,Container is a template template parameter, but your default for it
is a class. Something like this is legal

#include <list>
#include <memory>

template<
typename T1=int,
typename T2=double,
template<typename, typename> class Container = std::list >
class Relation
{
Container<T1, std::allocator<T1> > dom1;
};

int main(int argc, char* argv[])
{
Relation<> rel;
return 0;
}

Perhaps that's what you want?

John
 
J

John Harrison

John said:
Fraser said:
#include <list>
#include <memory>
#pragma hdrstop
template<
typename T1=int,
typename T2=double,
template<typename, typename> class Container=
std::list<T1, std::allocator<T1> > >
class Relation {
Container dom1;
};
#pragma argsused
int main(int argc, char* argv[])
{
Relation<> rel;
return 0;
}

Why do I get an undefined structure error for rel? Probably its a
compiler
bug or a language feature not implemented.

No,Container is a template template parameter, but your default for it
is a class. Something like this is legal

#include <list>
#include <memory>

template<
typename T1=int,
typename T2=double,
template<typename, typename> class Container = std::list >
class Relation
{
Container<T1, std::allocator<T1> > dom1;
};

int main(int argc, char* argv[])
{
Relation<> rel;
return 0;
}

Perhaps that's what you want?

Or maybe you really wanted this

#include <list>
#include <memory>

template<
typename T1=int,
typename T2=double,
class Container = std::list<T1> >
class Relation
{
Container dom1;
};

int main(int argc, char* argv[])
{
Relation<> rel;
return 0;
}

Anyway, you seem to have got the two possibilites confused.

john
 
F

Fraser Ross

I wanted a template template parameter with a default which I had wrong.

I am getting a internal compiler error with this with the function:
template <typename T1=char,
template <typename, typename> class T2=std::basic_ifstream>
class Implementation {
T2_tp<T1, std::char_traits<T1_tp> > Stream;
public:
T2_tp<T1, std::char_traits<T1> >& UseStream() {
return Stream;
};
 
J

John Harrison

Fraser said:
I wanted a template template parameter with a default which I had wrong.

I am getting a internal compiler error with this with the function:
template <typename T1=char,
template <typename, typename> class T2=std::basic_ifstream>
class Implementation {
T2_tp<T1, std::char_traits<T1_tp> > Stream;
public:
T2_tp<T1, std::char_traits<T1> >& UseStream() {
return Stream;
};

Well I replaced T1_tp and T2_tp with T1 and T2 and then it compiled fine
for me, MSVC++ 7.1.

john
 
F

Fraser Ross

That was a typo introduced while I simplified names. This error often comes
up when there is a compiler bug.

Fraser.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top