Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > incomplete return type in template function declaration; will c++0x'auto' work?

Reply
Thread Tools

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

 
 
m0shbear
Guest
Posts: n/a
 
      03-19-2011
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?

 
Reply With Quote
 
 
 
 
m0shbear
Guest
Posts: n/a
 
      03-19-2011
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Structure return type is an incomplete type. gk245 C Programming 2 05-06-2006 01:03 AM
Forward declaration & incomplete template type verec C++ 2 06-25-2005 02:21 PM
Template instantiation of std::list<> with incomplete type Mikhail N. Kupchik C++ 4 09-15-2004 07:27 PM
Incomplete type as template argument Andrew Ward C++ 7 02-25-2004 02:12 PM
Can a template function return a template type? Damon C++ 2 12-15-2003 12:56 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57