incomplete return type in template function declaration; will c++0x'auto' work?

M

m0shbear

Suppose I have the following classes: S T U, each of which is
incompatible with the others.
I want to have functions (ideally written) like this:
template<> T foo<0>(const S&);
template<> U foo<1>(const S&);

Will the template declaration
template<int IType> auto foo(const S&);
work?
Likewise for
template<int IType, class Ret> Ret foo(const S&);

The problem I see with the second one is that the expression
void bar() {
S s;
U u = foo<1>(s); // *
}
will be ill-formed.
Is such a notation for template foo<int>(const S&) even possible?
 
M

m0shbear

A clarification:
Can there exist a type lookup table to handle the mapping between the
template arg type and the return type?
As in:
lookup-table {
[ IType = 0 ] -> T
[ IType = 1 ] -> U
}

Basically, indirect template-dependent return types wherein the
mapping is only defined at specialization, and outside the template,
the return type is deduced from the specialization of said template.
 

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,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top