C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

EDG Bug?

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Joshua Lehrer
Guest





PostPosted: Mon Sep 22, 2003 10:31 pm    Post subject: EDG Bug? Reply with quote



I believe I have tracked this down to a bug in the EDG front end. The
problem is that it doesn't like the return type to be too complex.
The "choose" template throws it off. If you map the return type
through another class, and hide the "choose" template in the secondary
helper class, then it works fine, as demonstrated in this example:

My Compiler = Compaq C++ V6.5-033

EDG Version = 245?


//a template to "choose" at compile time between
//two types, given a boolean "true" or "false"
template <bool b, typename T1, typename T2> struct choose {
typedef T1 result;
};
template <typename T1, typename T2> struct choose<false,T1,T2> {
typedef T2 result;
};

//an example of a function which does not work
//when the return value is complex.
template <typename T>
typename choose<sizeof(T)==sizeof(int),T,int>::result
does_not_work(const T&);


//a helper class to "hide" the complexity of the return value
template <typename T> struct Helper {
typedef typename choose<sizeof(T)==sizeof(int),T,int>::result
result;
};

//an example of a function which does work with an equally complex
//return value, after mapping this return type through another
//class to make it appear simpler
template <typename T> typename Helper<T>::result works(const T&);

int main(int argc, char **argv) {
works('X');
does_not_work('X');
}


Error:


does_not_work('X');
.....................^
%CXX-E-BADTYPFROMINST, template instantiation resulted in unexpected
function type of "choose<false, char, int>::result (const char &)"
(the meaning of a name may have changed since the template
declaration -- the type of the template is
"choose<::result (const T &)")
detected during instantiation of "does_not_work" based on template
argument <char> at line 30

joshua lehrer
factset research systems
NYSE:FDS

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.