|
-
January 5th, 2009, 12:07 AM
#1
self-referencing policies
Hello,
I've just discovered policy based design (due to a forum topic a few days ago) and am having fun playing around with it. Here's a little question I ran into: I want my policy class to have a convenient label for the datatype inherent to its derived class. Here's my bare-bones example:
Code:
template<class T>
class policy{
public:
typedef typename T::fooType fooType;
};
template<class fooType>
class foo : public policy<foo<fooType> >{
};
int main(){
foo<int> F;
return 0;
}
This doesn't compile (gcc v4.1), because at the time the typedef is evaluated by the compiler, foo is not yet fully defined. Any ideas how to get around this? I know I could nix the typedef and use T::fooType explicitly, but that gets very messy in my "real world" example...
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
|