|
-
Apr 3rd, 2007, 07:46 AM
#1
Thread Starter
transcendental analytic
partial template specialization problem
Its only partial because gcc doesn't seem to like it otherwise nor does it seem to be allowed in the ISO standard, although I have a vague memory it used to work in MSVC..
Anyway, this gives me 0 (false) when its suppose to use the specialization - if I replace H with int in the specialization it works, but that would defeat the point.
PHP Code:
template <class H>
struct c{
template <class X,class T=void> struct h{
static const bool val=false;
};
template <class T> struct h<H,T>{
static const bool val=true;
};
};
int main(){
cout << c<int>::h<int>::val<<endl;
return 0;
}
Anyone know what the problem is, or know any workarounds? Does it work in MSVC (I recall you can't initialize the static constants in msvc inside the struct but have to do it outside, but my guess that was non standard) or any other compiler than gcc? Is it suppose to work (give 1) according to the ISO standard?
Last edited by kedaman; Apr 3rd, 2007 at 08:06 AM.
Reason: code formatting
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|